directionText 기존 있던 내용 제거

This commit is contained in:
hyojun.choi 2025-03-04 16:46:11 +09:00
parent 6a0072b058
commit d031c0d6e0
3 changed files with 33 additions and 24 deletions

View File

@ -159,7 +159,7 @@ export default function CanvasMenu(props) {
roof.set({ selectable: true }) roof.set({ selectable: true })
setSurfaceShapePattern(roof, null, false, roof.roofMaterial) setSurfaceShapePattern(roof, null, false, roof.roofMaterial)
delete roof.moduleCompass delete roof.moduleCompass
drawDirectionArrow(roof) drawDirectionArrow(roof, false)
}) })
} }
@ -184,13 +184,13 @@ export default function CanvasMenu(props) {
break break
case 'surface': case 'surface':
const modules = canvas.getObjects().filter((module) => module.name === POLYGON_TYPE.MODULE) const modules = canvas.getObjects().filter((module) => module.name === POLYGON_TYPE.MODULE)
initRoofs()
if (modules.length > 0) { if (modules.length > 0) {
swalFire({ swalFire({
text: getMessage('module.delete.confirm'), text: getMessage('module.delete.confirm'),
type: 'confirm', type: 'confirm',
confirmFn: () => { confirmFn: () => {
// //
initRoofs()
const moduleSurfacesArray = canvas const moduleSurfacesArray = canvas
.getObjects() .getObjects()
@ -204,6 +204,7 @@ export default function CanvasMenu(props) {
moduleSurfacesArray.forEach((moduleSurface) => { moduleSurfacesArray.forEach((moduleSurface) => {
canvas.remove(moduleSurface) canvas.remove(moduleSurface)
}) })
canvas.renderAll() canvas.renderAll()
onClickNav(menu) onClickNav(menu)
} }

View File

@ -27,6 +27,11 @@ export function useOrientation() {
setCompasDeg(0) setCompasDeg(0)
} }
const roofs = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF) const roofs = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF)
roofs.forEach((roof) => {
delete roof.directionText
})
roofs.forEach((roof) => { roofs.forEach((roof) => {
roof.set({ roof.set({
moduleCompass: isNaN(compasDeg) ? 0 : compasDeg, moduleCompass: isNaN(compasDeg) ? 0 : compasDeg,

View File

@ -172,8 +172,9 @@ export const usePolygon = () => {
/** /**
* poolygon의 방향에 따라 화살표를 추가한다. * poolygon의 방향에 따라 화살표를 추가한다.
* @param polygon * @param polygon
* @param showDirectionText
*/ */
const drawDirectionArrow = (polygon) => { const drawDirectionArrow = (polygon, showDirectionText = true) => {
if (polygon.points.length < 3) { if (polygon.points.length < 3) {
return return
} }
@ -319,17 +320,16 @@ export const usePolygon = () => {
pitch: polygon.roofMaterial?.pitch ?? 4, pitch: polygon.roofMaterial?.pitch ?? 4,
parentId: polygon.id, parentId: polygon.id,
}) })
arrow.setViewLengthText(false) arrow.setViewLengthText(false)
polygon.arrow = arrow polygon.arrow = arrow
polygon.canvas.add(arrow) polygon.canvas.add(arrow)
polygon.canvas.renderAll() polygon.canvas.renderAll()
drawDirectionStringToArrow2(polygon) drawDirectionStringToArrow2(polygon, showDirectionText)
// drawDirectionStringToArrow() // drawDirectionStringToArrow()
} }
//arrow의 compass 값으로 방향 글자 설정 필요 //arrow의 compass 값으로 방향 글자 설정 필요
const drawDirectionStringToArrow2 = (polygon) => { const drawDirectionStringToArrow2 = (polygon, showDirectionText) => {
const { direction, surfaceCompass, moduleCompass, arrow } = polygon const { direction, surfaceCompass, moduleCompass, arrow } = polygon
if (moduleCompass === null || moduleCompass === undefined) { if (moduleCompass === null || moduleCompass === undefined) {
const textObj = new fabric.Text(`${currentAngleType === ANGLE_TYPE.SLOPE ? arrow.pitch : getDegreeByChon(arrow.pitch)}${pitchText}`, { const textObj = new fabric.Text(`${currentAngleType === ANGLE_TYPE.SLOPE ? arrow.pitch : getDegreeByChon(arrow.pitch)}${pitchText}`, {
@ -510,24 +510,27 @@ export const usePolygon = () => {
text = text + (sameDirectionCnt.length + 1) text = text + (sameDirectionCnt.length + 1)
polygon.set('directionText', text) polygon.set('directionText', text)
const textObj = new fabric.Text(`${text} (${currentAngleType === ANGLE_TYPE.SLOPE ? arrow.pitch : getDegreeByChon(arrow.pitch)}${pitchText})`, { const textObj = new fabric.Text(
fontFamily: flowFontOptions.fontFamily.value, `${showDirectionText && text} (${currentAngleType === ANGLE_TYPE.SLOPE ? arrow.pitch : getDegreeByChon(arrow.pitch)}${pitchText})`,
fontWeight: flowFontOptions.fontWeight.value.toLowerCase().includes('bold') ? 'bold' : 'normal', {
fontStyle: flowFontOptions.fontWeight.value.toLowerCase().includes('italic') ? 'italic' : 'normal', fontFamily: flowFontOptions.fontFamily.value,
fontSize: flowFontOptions.fontSize.value, fontWeight: flowFontOptions.fontWeight.value.toLowerCase().includes('bold') ? 'bold' : 'normal',
fill: flowFontOptions.fontColor.value, fontStyle: flowFontOptions.fontWeight.value.toLowerCase().includes('italic') ? 'italic' : 'normal',
pitch: arrow.pitch, fontSize: flowFontOptions.fontSize.value,
originX: 'center', fill: flowFontOptions.fontColor.value,
originY: 'center', pitch: arrow.pitch,
name: 'flowText', originX: 'center',
originText: text, originY: 'center',
selectable: false, name: 'flowText',
left: arrow.stickeyPoint.x, originText: text,
top: arrow.stickeyPoint.y, selectable: false,
parent: arrow, left: arrow.stickeyPoint.x,
parentId: arrow.id, top: arrow.stickeyPoint.y,
visible: isFlowDisplay, parent: arrow,
}) parentId: arrow.id,
visible: isFlowDisplay,
},
)
polygon.canvas.add(textObj) polygon.canvas.add(textObj)
} }