Compare commits
No commits in common. "e9d0668ed2e864cfabc1b20d05ad5c9395fb8dd7" and "d67147063fa72714539f64444f3e47227a9b1caa" have entirely different histories.
e9d0668ed2
...
d67147063f
@ -32,7 +32,6 @@ import { useEvent } from '@/hooks/useEvent'
|
|||||||
import { compasDegAtom } from '@/store/orientationAtom'
|
import { compasDegAtom } from '@/store/orientationAtom'
|
||||||
import { hotkeyStore } from '@/store/hotkeyAtom'
|
import { hotkeyStore } from '@/store/hotkeyAtom'
|
||||||
import { usePopup } from '@/hooks/usePopup'
|
import { usePopup } from '@/hooks/usePopup'
|
||||||
import { outerLinePointsState } from '@/store/outerLineAtom'
|
|
||||||
|
|
||||||
export default function CanvasFrame() {
|
export default function CanvasFrame() {
|
||||||
const canvasRef = useRef(null)
|
const canvasRef = useRef(null)
|
||||||
@ -46,7 +45,6 @@ export default function CanvasFrame() {
|
|||||||
const totalDisplay = useRecoilValue(totalDisplaySelector) // 집계표 표시 여부
|
const totalDisplay = useRecoilValue(totalDisplaySelector) // 집계표 표시 여부
|
||||||
const { setIsGlobalLoading } = useContext(QcastContext)
|
const { setIsGlobalLoading } = useContext(QcastContext)
|
||||||
const resetModuleStatisticsState = useResetRecoilState(moduleStatisticsState)
|
const resetModuleStatisticsState = useResetRecoilState(moduleStatisticsState)
|
||||||
const resetOuterLinePoints = useResetRecoilState(outerLinePointsState)
|
|
||||||
const resetMakersState = useResetRecoilState(makersState)
|
const resetMakersState = useResetRecoilState(makersState)
|
||||||
const resetSelectedMakerState = useResetRecoilState(selectedMakerState)
|
const resetSelectedMakerState = useResetRecoilState(selectedMakerState)
|
||||||
const resetSeriesState = useResetRecoilState(seriesState)
|
const resetSeriesState = useResetRecoilState(seriesState)
|
||||||
@ -139,7 +137,6 @@ export default function CanvasFrame() {
|
|||||||
|
|
||||||
const resetRecoilData = () => {
|
const resetRecoilData = () => {
|
||||||
// resetModuleStatisticsState()
|
// resetModuleStatisticsState()
|
||||||
resetOuterLinePoints()
|
|
||||||
resetMakersState()
|
resetMakersState()
|
||||||
resetSelectedMakerState()
|
resetSelectedMakerState()
|
||||||
resetSeriesState()
|
resetSeriesState()
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useRef, useState } from 'react'
|
import { useState, useEffect, useRef } from 'react'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import WithDraggable from '@/components/common/draggable/WithDraggable'
|
import WithDraggable from '@/components/common/draggable/WithDraggable'
|
||||||
import { useRecoilValue } from 'recoil'
|
import { useRecoilValue } from 'recoil'
|
||||||
@ -15,8 +15,8 @@ export default function DormerOffset(props) {
|
|||||||
const { closePopup } = usePopup()
|
const { closePopup } = usePopup()
|
||||||
const [arrow1, setArrow1] = useState(null)
|
const [arrow1, setArrow1] = useState(null)
|
||||||
const [arrow2, setArrow2] = useState(null)
|
const [arrow2, setArrow2] = useState(null)
|
||||||
const arrow1LengthRef = useRef(0)
|
const arrow1LengthRef = useRef()
|
||||||
const arrow2LengthRef = useRef(0)
|
const arrow2LengthRef = useRef()
|
||||||
const [arrow1Length, setArrow1Length] = useState(0)
|
const [arrow1Length, setArrow1Length] = useState(0)
|
||||||
const [arrow2Length, setArrow2Length] = useState(0)
|
const [arrow2Length, setArrow2Length] = useState(0)
|
||||||
|
|
||||||
@ -59,12 +59,12 @@ export default function DormerOffset(props) {
|
|||||||
name=""
|
name=""
|
||||||
label=""
|
label=""
|
||||||
className="input-origin block"
|
className="input-origin block"
|
||||||
value={arrow1LengthRef.current.value ?? 0}
|
value={arrow1LengthRef.current.value}
|
||||||
ref={arrow1LengthRef}
|
ref={arrow1LengthRef}
|
||||||
onChange={(value) => setArrow1Length(value)}
|
onChange={(value) => setArrow1Length(value)}
|
||||||
options={{
|
options={{
|
||||||
allowNegative: false,
|
allowNegative: false,
|
||||||
allowDecimal: false,
|
allowDecimal: false
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -648,7 +648,6 @@ export function useCommonUtils() {
|
|||||||
lockMovementY: true,
|
lockMovementY: true,
|
||||||
name: obj.name,
|
name: obj.name,
|
||||||
editable: false,
|
editable: false,
|
||||||
selectable: true, // 복사된 객체 선택 가능하도록 설정
|
|
||||||
id: uuidv4(), //복사된 객체라 새로 따준다
|
id: uuidv4(), //복사된 객체라 새로 따준다
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -657,25 +656,19 @@ export function useCommonUtils() {
|
|||||||
|
|
||||||
//배치면일 경우
|
//배치면일 경우
|
||||||
if (obj.name === 'roof') {
|
if (obj.name === 'roof') {
|
||||||
clonedObj.canvas = canvas // canvas 참조 설정
|
clonedObj.setCoords()
|
||||||
|
clonedObj.fire('modified')
|
||||||
|
// clonedObj.fire('polygonMoved')
|
||||||
clonedObj.set({
|
clonedObj.set({
|
||||||
direction: obj.direction,
|
direction: obj.direction,
|
||||||
directionText: obj.directionText,
|
directionText: obj.directionText,
|
||||||
roofMaterial: obj.roofMaterial,
|
roofMaterial: obj.roofMaterial,
|
||||||
stroke: 'black', // 복사된 객체는 선택 해제 상태의 색상으로 설정
|
|
||||||
selectable: true, // 선택 가능하도록 설정
|
|
||||||
evented: true, // 마우스 이벤트를 받을 수 있도록 설정
|
|
||||||
isFixed: false, // containsPoint에서 특별 처리 방지
|
|
||||||
})
|
})
|
||||||
|
|
||||||
obj.lines.forEach((line, index) => {
|
obj.lines.forEach((line, index) => {
|
||||||
clonedObj.lines[index].set({ attributes: line.attributes })
|
clonedObj.lines[index].set({ attributes: line.attributes })
|
||||||
})
|
})
|
||||||
|
|
||||||
clonedObj.fire('polygonMoved') // 내부 좌표 재계산 (points, pathOffset)
|
|
||||||
clonedObj.fire('modified')
|
|
||||||
clonedObj.setCoords() // 모든 속성 설정 후 좌표 업데이트
|
|
||||||
canvas.setActiveObject(clonedObj)
|
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
addLengthText(clonedObj) //수치 추가
|
addLengthText(clonedObj) //수치 추가
|
||||||
drawDirectionArrow(clonedObj) //방향 화살표 추가
|
drawDirectionArrow(clonedObj) //방향 화살표 추가
|
||||||
|
|||||||
@ -372,18 +372,11 @@ export function useRoofAllocationSetting(id) {
|
|||||||
setBasicSetting((prev) => {
|
setBasicSetting((prev) => {
|
||||||
return { ...prev, selectedRoofMaterial: newRoofList.find((roof) => roof.selected) }
|
return { ...prev, selectedRoofMaterial: newRoofList.find((roof) => roof.selected) }
|
||||||
})
|
})
|
||||||
const selectedRoofMaterial = newRoofList.find((roof) => roof.selected)
|
|
||||||
const roofs = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF && obj.roofMaterial?.index === selectedRoofMaterial.index)
|
|
||||||
|
|
||||||
roofs.forEach((roof) => {
|
|
||||||
setSurfaceShapePattern(roof, roofDisplay.column, false, { ...selectedRoofMaterial }, true)
|
|
||||||
drawDirectionArrow(roof)
|
|
||||||
})
|
|
||||||
|
|
||||||
setRoofList(newRoofList)
|
setRoofList(newRoofList)
|
||||||
setRoofMaterials(newRoofList)
|
setRoofMaterials(newRoofList)
|
||||||
setRoofsStore(newRoofList)
|
setRoofsStore(newRoofList)
|
||||||
|
const selectedRoofMaterial = newRoofList.find((roof) => roof.selected)
|
||||||
setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial, true)
|
setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial, true)
|
||||||
drawDirectionArrow(currentObject)
|
drawDirectionArrow(currentObject)
|
||||||
modifyModuleSelectionData()
|
modifyModuleSelectionData()
|
||||||
|
|||||||
@ -29,39 +29,22 @@ fabric.Rect.prototype.getCurrentPoints = function () {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* fabric.Group에 getCurrentPoints 메서드를 추가 (도머 그룹용)
|
* fabric.Group에 getCurrentPoints 메서드를 추가 (도머 그룹용)
|
||||||
* 그룹 내 객체들의 점들을 수집하여 현재 월드 좌표를 반환
|
* 그룹의 groupPoints를 다시 계산하여 반환
|
||||||
*/
|
*/
|
||||||
fabric.Group.prototype.getCurrentPoints = function () {
|
fabric.Group.prototype.getCurrentPoints = function () {
|
||||||
// 그룹 내 객체들로부터 실시간으로 점들을 계산
|
// groupPoints를 다시 계산
|
||||||
if (this._objects && this._objects.length > 0) {
|
|
||||||
let allPoints = []
|
|
||||||
|
|
||||||
// 그룹 내 모든 객체의 점들을 수집
|
// 그룹에 groupPoints가 있으면 해당 점들을 사용 (도머의 경우)
|
||||||
this._objects.forEach(function (obj) {
|
if (this.groupPoints && Array.isArray(this.groupPoints)) {
|
||||||
if (obj.getCurrentPoints && typeof obj.getCurrentPoints === 'function') {
|
const matrix = this.calcTransformMatrix()
|
||||||
const objPoints = obj.getCurrentPoints()
|
console.log('this.groupPoints', this.groupPoints)
|
||||||
allPoints = allPoints.concat(objPoints)
|
return this.groupPoints.map(function (p) {
|
||||||
} else if (obj.points && Array.isArray(obj.points)) {
|
const point = new fabric.Point(p.x, p.y)
|
||||||
const pathOffset = obj.pathOffset || { x: 0, y: 0 }
|
return fabric.util.transformPoint(point, matrix)
|
||||||
const matrix = obj.calcTransformMatrix()
|
|
||||||
const transformedPoints = obj.points
|
|
||||||
.map(function (p) {
|
|
||||||
return new fabric.Point(p.x - pathOffset.x, p.y - pathOffset.y)
|
|
||||||
})
|
})
|
||||||
.map(function (p) {
|
|
||||||
return fabric.util.transformPoint(p, matrix)
|
|
||||||
})
|
|
||||||
allPoints = allPoints.concat(transformedPoints)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (allPoints.length > 0) {
|
|
||||||
// Convex Hull 알고리즘을 사용하여 외곽 점들만 반환
|
|
||||||
return this.getConvexHull(allPoints)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 객체가 없으면 바운딩 박스를 사용
|
// groupPoints가 없으면 바운딩 박스를 사용
|
||||||
const bounds = this.getBoundingRect()
|
const bounds = this.getBoundingRect()
|
||||||
const points = [
|
const points = [
|
||||||
{ x: bounds.left, y: bounds.top },
|
{ x: bounds.left, y: bounds.top },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user