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