From 021e425c84ae334ce489d9c6ecab5931ae6db906 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Tue, 10 Dec 2024 14:36:29 +0900 Subject: [PATCH] =?UTF-8?q?QPolygon=20containsPoint=20=EB=8B=A8=EA=B3=84?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EB=8B=A4=EB=A5=B4=EA=B2=8C=20?= =?UTF-8?q?=EC=9E=91=EB=8F=99=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/fabric/QPolygon.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/fabric/QPolygon.js b/src/components/fabric/QPolygon.js index 0f7bd815..0ec436fe 100644 --- a/src/components/fabric/QPolygon.js +++ b/src/components/fabric/QPolygon.js @@ -4,7 +4,7 @@ import { QLine } from '@/components/fabric/QLine' import { distanceBetweenPoints, findTopTwoIndexesByDistance, getDirectionByPoint, sortedPointLessEightPoint, sortedPoints } from '@/util/canvas-util' import { calculateAngle, drawGabledRoof, drawRidgeRoof, drawShedRoof, inPolygon, toGeoJSON } from '@/util/qpolygon-utils' import * as turf from '@turf/turf' -import { LINE_TYPE } from '@/common/common' +import { LINE_TYPE, POLYGON_TYPE } from '@/common/common' export const QPolygon = fabric.util.createClass(fabric.Polygon, { type: 'QPolygon', @@ -690,6 +690,15 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { return intersects % 2 === 1 }, + containsPoint: function (point) { + if (this.name === POLYGON_TYPE.ROOF && this.isFixed) { + const isInside = this.inPolygon(point) + this.set('selectable', isInside) + return isInside + } else { + return this.callSuper('containsPoint', point) + } + }, inPolygonABType(x, y, polygon) { let inside = false