치수선 property 추가
This commit is contained in:
parent
7f90a9f18a
commit
bc3a19d041
@ -31,6 +31,7 @@ export default function DimensionLineSetting(props) {
|
||||
useEffect(() => {
|
||||
if (canvas) {
|
||||
const dimensionObject = canvas.getActiveObject()
|
||||
console.log(dimensionObject)
|
||||
const id = dimensionObject.groupId
|
||||
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0]
|
||||
if (!textObj) return
|
||||
@ -38,6 +39,7 @@ export default function DimensionLineSetting(props) {
|
||||
setBasicLength(+dimensionObject.length)
|
||||
setSelectedSlope1(dimensionObject.angle1)
|
||||
setSelectedSlope2(dimensionObject.angle2)
|
||||
setSlopeAble(dimensionObject.slopeAble)
|
||||
}
|
||||
|
||||
if (basicSetting.roofAngleSet === 'slope') {
|
||||
@ -65,13 +67,13 @@ export default function DimensionLineSetting(props) {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!slopeAble) {
|
||||
const dimensionObject = canvas.getActiveObject()
|
||||
dimensionObject.set({
|
||||
angle1: null,
|
||||
angle2: null,
|
||||
})
|
||||
}
|
||||
// if (!slopeAble) {
|
||||
// const dimensionObject = canvas.getActiveObject()
|
||||
// dimensionObject.set({
|
||||
// angle1: null,
|
||||
// angle2: null,
|
||||
// })
|
||||
// }
|
||||
}, [slopeAble])
|
||||
|
||||
const handleChangeLength = () => {
|
||||
@ -79,19 +81,24 @@ export default function DimensionLineSetting(props) {
|
||||
const dimensionObject = canvas.getActiveObject()
|
||||
const id = dimensionObject.groupId
|
||||
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0]
|
||||
let resultText = +changeLength > 0 ? +changeLength : '0'
|
||||
console.log(changeLength)
|
||||
let resultText = +changeLength > 0 ? +changeLength : dimensionObject.length
|
||||
|
||||
if (slopeAble) {
|
||||
resultText = !selectedSlope2
|
||||
? calculateLength(basicLength, selectedSlope1.value).toFixed(0)
|
||||
: calculateLength(basicLength, selectedSlope1.value, selectedSlope2.value).toFixed(0)
|
||||
? calculateLength(resultText, selectedSlope1.value).toFixed(0)
|
||||
: calculateLength(resultText, selectedSlope1.value, selectedSlope2.value).toFixed(0)
|
||||
}
|
||||
|
||||
textObj.set({
|
||||
text: String(resultText),
|
||||
})
|
||||
|
||||
dimensionObject.set({ length: +resultText })
|
||||
dimensionObject.set({
|
||||
length: +changeLength > 0 ? +changeLength : dimensionObject.length,
|
||||
slopeAble: slopeAble,
|
||||
angle1: selectedSlope1,
|
||||
angle2: selectedSlope2,
|
||||
})
|
||||
setBasicLength(resultText)
|
||||
setChangeLength('')
|
||||
canvas.renderAll()
|
||||
@ -153,7 +160,7 @@ export default function DimensionLineSetting(props) {
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -282,6 +282,10 @@ export function useCommonUtils() {
|
||||
originY: 'center',
|
||||
lineDirection: lineDirection,
|
||||
groupId: uuid,
|
||||
length: distance * 10,
|
||||
slopeAble: false,
|
||||
angle1: null,
|
||||
angle2: null,
|
||||
})
|
||||
|
||||
canvas.add(group)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user