치수선 property 추가

This commit is contained in:
김민식 2025-02-27 18:13:58 +09:00
parent 7f90a9f18a
commit bc3a19d041
2 changed files with 24 additions and 13 deletions

View File

@ -31,6 +31,7 @@ export default function DimensionLineSetting(props) {
useEffect(() => { useEffect(() => {
if (canvas) { if (canvas) {
const dimensionObject = canvas.getActiveObject() const dimensionObject = canvas.getActiveObject()
console.log(dimensionObject)
const id = dimensionObject.groupId const id = dimensionObject.groupId
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0] const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0]
if (!textObj) return if (!textObj) return
@ -38,6 +39,7 @@ export default function DimensionLineSetting(props) {
setBasicLength(+dimensionObject.length) setBasicLength(+dimensionObject.length)
setSelectedSlope1(dimensionObject.angle1) setSelectedSlope1(dimensionObject.angle1)
setSelectedSlope2(dimensionObject.angle2) setSelectedSlope2(dimensionObject.angle2)
setSlopeAble(dimensionObject.slopeAble)
} }
if (basicSetting.roofAngleSet === 'slope') { if (basicSetting.roofAngleSet === 'slope') {
@ -65,13 +67,13 @@ export default function DimensionLineSetting(props) {
}, []) }, [])
useEffect(() => { useEffect(() => {
if (!slopeAble) { // if (!slopeAble) {
const dimensionObject = canvas.getActiveObject() // const dimensionObject = canvas.getActiveObject()
dimensionObject.set({ // dimensionObject.set({
angle1: null, // angle1: null,
angle2: null, // angle2: null,
}) // })
} // }
}, [slopeAble]) }, [slopeAble])
const handleChangeLength = () => { const handleChangeLength = () => {
@ -79,19 +81,24 @@ export default function DimensionLineSetting(props) {
const dimensionObject = canvas.getActiveObject() const dimensionObject = canvas.getActiveObject()
const id = dimensionObject.groupId const id = dimensionObject.groupId
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0] const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0]
let resultText = +changeLength > 0 ? +changeLength : '0' let resultText = +changeLength > 0 ? +changeLength : dimensionObject.length
console.log(changeLength)
if (slopeAble) { if (slopeAble) {
resultText = !selectedSlope2 resultText = !selectedSlope2
? calculateLength(basicLength, selectedSlope1.value).toFixed(0) ? calculateLength(resultText, selectedSlope1.value).toFixed(0)
: calculateLength(basicLength, selectedSlope1.value, selectedSlope2.value).toFixed(0) : calculateLength(resultText, selectedSlope1.value, selectedSlope2.value).toFixed(0)
} }
textObj.set({ textObj.set({
text: String(resultText), text: String(resultText),
}) })
dimensionObject.set({ length: +resultText }) dimensionObject.set({
length: +changeLength > 0 ? +changeLength : dimensionObject.length,
slopeAble: slopeAble,
angle1: selectedSlope1,
angle2: selectedSlope2,
})
setBasicLength(resultText) setBasicLength(resultText)
setChangeLength('') setChangeLength('')
canvas.renderAll() canvas.renderAll()
@ -153,7 +160,7 @@ export default function DimensionLineSetting(props) {
</div> </div>
</div> </div>
<div className="d-check-box pop"> <div className="d-check-box pop">
<input type="checkbox" id="ch99" onChange={() => setSlopeAble(!slopeAble)} /> <input type="checkbox" id="ch99" checked={slopeAble} onChange={() => setSlopeAble(!slopeAble)} />
<label htmlFor="ch99">{getMessage('modal.display.edit.input.slope')}</label> <label htmlFor="ch99">{getMessage('modal.display.edit.input.slope')}</label>
</div> </div>
</div> </div>

View File

@ -282,6 +282,10 @@ export function useCommonUtils() {
originY: 'center', originY: 'center',
lineDirection: lineDirection, lineDirection: lineDirection,
groupId: uuid, groupId: uuid,
length: distance * 10,
slopeAble: false,
angle1: null,
angle2: null,
}) })
canvas.add(group) canvas.add(group)