lengthText, 화살표 좌표 수정

This commit is contained in:
hyojun.choi 2024-10-16 17:16:58 +09:00
parent c4a513f003
commit 8ffdf5dca9
3 changed files with 48 additions and 29 deletions

View File

@ -201,7 +201,25 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
const dy = end.y - start.y const dy = end.y - start.y
const length = Number(Math.sqrt(dx * dx + dy * dy).toFixed(1)) * 10 const length = Number(Math.sqrt(dx * dx + dy * dy).toFixed(1)) * 10
const midPoint = new fabric.Point((start.x + end.x) / 2, (start.y + end.y) / 2) let midPoint
switch (this.direction) {
case 'north':
midPoint = new fabric.Point((start.x + end.x) / 2, (start.y + end.y) / 2 - 30)
break
case 'west':
midPoint = new fabric.Point((start.x + end.x) / 2 - 30, (start.y + end.y) / 2)
break
case 'south':
midPoint = new fabric.Point((start.x + end.x) / 2, (start.y + end.y) / 2 + 30)
break
case 'east':
midPoint = new fabric.Point((start.x + end.x) / 2 + 30, (start.y + end.y) / 2)
break
default:
midPoint = new fabric.Point((start.x + end.x) / 2, (start.y + end.y) / 2)
break
}
const degree = (Math.atan2(dy, dx) * 180) / Math.PI const degree = (Math.atan2(dy, dx) * 180) / Math.PI

View File

@ -1694,6 +1694,7 @@ export function useMode() {
const polygon = createRoofPolygon(wall.points) const polygon = createRoofPolygon(wall.points)
const originPolygon = new QPolygon(wall.points, { fontSize: 0 }) const originPolygon = new QPolygon(wall.points, { fontSize: 0 })
originPolygon.setViewLengthText(false)
let offsetPolygon let offsetPolygon
let result = createMarginPolygon(polygon, wall.lines).vertices let result = createMarginPolygon(polygon, wall.lines).vertices

View File

@ -3072,58 +3072,58 @@ export const drawDirectionArrow = (polygon) => {
switch (direction) { switch (direction) {
case 'north': case 'north':
points = [ points = [
{ x: centerPoint.x, y: polygonMinY - 20 }, { x: centerPoint.x, y: polygonMinY - 50 },
{ x: centerPoint.x + 20, y: polygonMinY - 20 },
{ x: centerPoint.x + 20, y: polygonMinY - 50 }, { x: centerPoint.x + 20, y: polygonMinY - 50 },
{ x: centerPoint.x + 50, y: polygonMinY - 50 }, { x: centerPoint.x + 20, y: polygonMinY - 80 },
{ x: centerPoint.x, y: polygonMinY - 80 }, { x: centerPoint.x + 50, y: polygonMinY - 80 },
{ x: centerPoint.x - 50, y: polygonMinY - 50 }, { x: centerPoint.x, y: polygonMinY - 110 },
{ x: centerPoint.x - 50, y: polygonMinY - 80 },
{ x: centerPoint.x - 20, y: polygonMinY - 80 },
{ x: centerPoint.x - 20, y: polygonMinY - 50 }, { x: centerPoint.x - 20, y: polygonMinY - 50 },
{ x: centerPoint.x - 20, y: polygonMinY - 20 },
] ]
stickeyPoint = { x: centerPoint.x, y: polygonMinY - 80 } stickeyPoint = { x: centerPoint.x, y: polygonMinY - 110 }
break break
case 'south': case 'south':
points = [ points = [
{ x: centerPoint.x, y: polygonMaxY + 20 }, { x: centerPoint.x, y: polygonMaxY + 50 },
{ x: centerPoint.x + 20, y: polygonMaxY + 20 },
{ x: centerPoint.x + 20, y: polygonMaxY + 50 }, { x: centerPoint.x + 20, y: polygonMaxY + 50 },
{ x: centerPoint.x + 50, y: polygonMaxY + 50 }, { x: centerPoint.x + 20, y: polygonMaxY + 80 },
{ x: centerPoint.x, y: polygonMaxY + 80 }, { x: centerPoint.x + 50, y: polygonMaxY + 80 },
{ x: centerPoint.x - 50, y: polygonMaxY + 50 }, { x: centerPoint.x, y: polygonMaxY + 110 },
{ x: centerPoint.x - 50, y: polygonMaxY + 80 },
{ x: centerPoint.x - 20, y: polygonMaxY + 80 },
{ x: centerPoint.x - 20, y: polygonMaxY + 50 }, { x: centerPoint.x - 20, y: polygonMaxY + 50 },
{ x: centerPoint.x - 20, y: polygonMaxY + 20 },
] ]
stickeyPoint = { x: centerPoint.x, y: polygonMaxY + 80 } stickeyPoint = { x: centerPoint.x, y: polygonMaxY + 110 }
break break
case 'west': case 'west':
points = [ points = [
{ x: polygonMinX - 20, y: centerPoint.y }, { x: polygonMinX - 50, y: centerPoint.y },
{ x: polygonMinX - 20, y: centerPoint.y + 20 },
{ x: polygonMinX - 50, y: centerPoint.y + 20 }, { x: polygonMinX - 50, y: centerPoint.y + 20 },
{ x: polygonMinX - 50, y: centerPoint.y + 50 }, { x: polygonMinX - 80, y: centerPoint.y + 20 },
{ x: polygonMinX - 80, y: centerPoint.y }, { x: polygonMinX - 80, y: centerPoint.y + 50 },
{ x: polygonMinX - 50, y: centerPoint.y - 50 }, { x: polygonMinX - 110, y: centerPoint.y },
{ x: polygonMinX - 80, y: centerPoint.y - 50 },
{ x: polygonMinX - 80, y: centerPoint.y - 20 },
{ x: polygonMinX - 50, y: centerPoint.y - 20 }, { x: polygonMinX - 50, y: centerPoint.y - 20 },
{ x: polygonMinX - 20, y: centerPoint.y - 20 },
] ]
stickeyPoint = { x: polygonMinX - 80, y: centerPoint.y } stickeyPoint = { x: polygonMinX - 110, y: centerPoint.y }
break break
case 'east': case 'east':
points = [ points = [
{ x: polygonMaxX + 20, y: centerPoint.y }, { x: polygonMaxX + 50, y: centerPoint.y },
{ x: polygonMaxX + 20, y: centerPoint.y + 20 },
{ x: polygonMaxX + 50, y: centerPoint.y + 20 }, { x: polygonMaxX + 50, y: centerPoint.y + 20 },
{ x: polygonMaxX + 50, y: centerPoint.y + 50 }, { x: polygonMaxX + 80, y: centerPoint.y + 20 },
{ x: polygonMaxX + 80, y: centerPoint.y }, { x: polygonMaxX + 80, y: centerPoint.y + 50 },
{ x: polygonMaxX + 50, y: centerPoint.y - 50 }, { x: polygonMaxX + 110, y: centerPoint.y },
{ x: polygonMaxX + 80, y: centerPoint.y - 50 },
{ x: polygonMaxX + 80, y: centerPoint.y - 20 },
{ x: polygonMaxX + 50, y: centerPoint.y - 20 }, { x: polygonMaxX + 50, y: centerPoint.y - 20 },
{ x: polygonMaxX + 20, y: centerPoint.y - 20 },
] ]
stickeyPoint = { x: polygonMaxX + 80, y: centerPoint.y } stickeyPoint = { x: polygonMaxX + 110, y: centerPoint.y }
break break
} }