QPolygon containsPoint 단계에 따라 다르게 작동하도록 수정

This commit is contained in:
hyojun.choi 2024-12-10 14:36:29 +09:00
parent 9c5e21aa41
commit 021e425c84

View File

@ -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