From 5102fa2ec08ae9a878340c3b3dcfc571beeb53f0 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 11 Jul 2025 14:09:50 +0900 Subject: [PATCH 1/3] =?UTF-8?q?polygon=20=EC=84=A0=ED=83=9D=EC=9D=B4=20?= =?UTF-8?q?=EC=9E=98=20=EC=95=88=EB=90=98=EB=8A=94=20=ED=98=84=EC=83=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/fabric/QPolygon.js | 153 +++++++++++++++++++++++++----- 1 file changed, 128 insertions(+), 25 deletions(-) diff --git a/src/components/fabric/QPolygon.js b/src/components/fabric/QPolygon.js index 264d62d1..a1a5a169 100644 --- a/src/components/fabric/QPolygon.js +++ b/src/components/fabric/QPolygon.js @@ -721,8 +721,7 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { } // Ray casting 알고리즘 - if (((yi > testY) !== (yj > testY)) && - (testX < (xj - xi) * (testY - yi) / (yj - yi) + xi)) { + if (yi > testY !== yj > testY && testX < ((xj - xi) * (testY - yi)) / (yj - yi) + xi) { inside = !inside } } @@ -739,7 +738,7 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { // 벡터의 외적을 계산하여 점이 선분 위에 있는지 확인 const crossProduct = Math.abs(dxPoint * dySegment - dyPoint * dxSegment) - + if (crossProduct > tolerance) { return false } @@ -747,7 +746,7 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { // 점이 선분의 범위 내에 있는지 확인 const dotProduct = dxPoint * dxSegment + dyPoint * dySegment const squaredLength = dxSegment * dxSegment + dySegment * dySegment - + return dotProduct >= 0 && dotProduct <= squaredLength }, setCoords: function () { @@ -773,36 +772,140 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { // 먼저 좌표 업데이트 this.setCoords() - // 캔버스 줌과 viewport transform 고려한 좌표 변환 - let localPoint = point - if (this.canvas) { + // 기본 Fabric.js bounding box 체크 먼저 수행 + if (!this.callSuper('containsPoint', point)) { + return false + } + + // 줌 레벨에 관계없이 안정적인 좌표 변환 + const matrix = this.calcTransformMatrix() + const invertedMatrix = fabric.util.invertTransform(matrix) + + // 캔버스 줌 고려 + let testPoint = point + if (this.canvas && this.canvas.viewportTransform) { const vpt = this.canvas.viewportTransform - if (vpt) { - // viewport transform 역변환 - const inverted = fabric.util.invertTransform(vpt) - localPoint = fabric.util.transformPoint(point, inverted) + const invertedVpt = fabric.util.invertTransform(vpt) + testPoint = fabric.util.transformPoint(point, invertedVpt) + } + + // 오브젝트 좌표계로 변환 + const localPoint = fabric.util.transformPoint(testPoint, invertedMatrix) + + // pathOffset 적용 + const pathOffset = this.get('pathOffset') + const finalPoint = { + x: localPoint.x + pathOffset.x, + y: localPoint.y + pathOffset.y, + } + + // 단순하고 안정적인 point-in-polygon 알고리즘 사용 + return this.simplePointInPolygon(finalPoint, this.get('points')) + }, + + simplePointInPolygon: function (point, polygon) { + const x = point.x + const y = point.y + let inside = false + + for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) { + const xi = polygon[i].x + const yi = polygon[i].y + const xj = polygon[j].x + const yj = polygon[j].y + + if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) { + inside = !inside } } - // 오브젝트의 transform matrix를 고려한 좌표 변환 - const matrix = this.calcTransformMatrix() - const invertedMatrix = fabric.util.invertTransform(matrix) - const transformedPoint = fabric.util.transformPoint(localPoint, invertedMatrix) + return inside + }, - // pathOffset을 고려한 최종 좌표 계산 - const pathOffset = this.get('pathOffset') - const finalPoint = { - x: transformedPoint.x + pathOffset.x, - y: transformedPoint.y + pathOffset.y, + isPointInPolygonRobust: function (point, polygon) { + const x = point.x + const y = point.y + let inside = false + + // 부동소수점 정밀도를 고려한 허용 오차 + const epsilon = 1e-10 + + for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) { + const xi = polygon[i].x + const yi = polygon[i].y + const xj = polygon[j].x + const yj = polygon[j].y + + // 점이 정점 위에 있는지 확인 (확장된 허용 오차) + if (Math.abs(xi - x) < 0.5 && Math.abs(yi - y) < 0.5) { + return true + } + + // 점이 선분 위에 있는지 확인 + if (this.isPointOnLineSegment(point, { x: xi, y: yi }, { x: xj, y: yj })) { + return true + } + + // Ray casting 알고리즘 - 개선된 버전 + if (Math.abs(yi - yj) > epsilon) { + const minY = Math.min(yi, yj) + const maxY = Math.max(yi, yj) + + if (y > minY && y <= maxY) { + // 교차점 계산 + const intersectionX = xi + ((y - yi) / (yj - yi)) * (xj - xi) + if (intersectionX > x) { + inside = !inside + } + } + } } - if (this.name === POLYGON_TYPE.ROOF && this.isFixed) { - const isInside = this.inPolygonImproved(finalPoint) - this.set('selectable', isInside) - return isInside + return inside + }, + + isPointOnLineSegment: function (point, lineStart, lineEnd) { + const tolerance = 2.0 // 더 큰 허용 오차 + const x = point.x + const y = point.y + const x1 = lineStart.x + const y1 = lineStart.y + const x2 = lineEnd.x + const y2 = lineEnd.y + + // 선분의 길이가 0인 경우 (점) + if (Math.abs(x2 - x1) < 1e-10 && Math.abs(y2 - y1) < 1e-10) { + return Math.abs(x - x1) < tolerance && Math.abs(y - y1) < tolerance + } + + // 점과 선분 사이의 거리 계산 + const A = x - x1 + const B = y - y1 + const C = x2 - x1 + const D = y2 - y1 + + const dot = A * C + B * D + const lenSq = C * C + D * D + const param = dot / lenSq + + let xx, yy + + if (param < 0 || (x1 === x2 && y1 === y2)) { + xx = x1 + yy = y1 + } else if (param > 1) { + xx = x2 + yy = y2 } else { - return this.inPolygonImproved(finalPoint) + xx = x1 + param * C + yy = y1 + param * D } + + const dx = x - xx + const dy = y - yy + const distance = Math.sqrt(dx * dx + dy * dy) + + return distance < tolerance }, inPolygonABType(x, y, polygon) { From 47a8274fd076d99d1b0f81970d2a983b9b4dae0e Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 11 Jul 2025 14:34:52 +0900 Subject: [PATCH 2/3] =?UTF-8?q?QPolygon=20=EC=84=A0=ED=83=9D=EC=98=81?= =?UTF-8?q?=EC=97=AD=20=EC=9B=90=EB=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/fabric/QPolygon.js | 142 ++++-------------------------- 1 file changed, 19 insertions(+), 123 deletions(-) diff --git a/src/components/fabric/QPolygon.js b/src/components/fabric/QPolygon.js index a1a5a169..ebf4e625 100644 --- a/src/components/fabric/QPolygon.js +++ b/src/components/fabric/QPolygon.js @@ -772,140 +772,36 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { // 먼저 좌표 업데이트 this.setCoords() - // 기본 Fabric.js bounding box 체크 먼저 수행 - if (!this.callSuper('containsPoint', point)) { - return false + // 캔버스 줌과 viewport transform 고려한 좌표 변환 + let localPoint = point + if (this.canvas) { + const vpt = this.canvas.viewportTransform + if (vpt) { + // viewport transform 역변환 + const inverted = fabric.util.invertTransform(vpt) + localPoint = fabric.util.transformPoint(point, inverted) + } } - // 줌 레벨에 관계없이 안정적인 좌표 변환 + // 오브젝트의 transform matrix를 고려한 좌표 변환 const matrix = this.calcTransformMatrix() const invertedMatrix = fabric.util.invertTransform(matrix) + const transformedPoint = fabric.util.transformPoint(localPoint, invertedMatrix) - // 캔버스 줌 고려 - let testPoint = point - if (this.canvas && this.canvas.viewportTransform) { - const vpt = this.canvas.viewportTransform - const invertedVpt = fabric.util.invertTransform(vpt) - testPoint = fabric.util.transformPoint(point, invertedVpt) - } - - // 오브젝트 좌표계로 변환 - const localPoint = fabric.util.transformPoint(testPoint, invertedMatrix) - - // pathOffset 적용 + // pathOffset을 고려한 최종 좌표 계산 const pathOffset = this.get('pathOffset') const finalPoint = { - x: localPoint.x + pathOffset.x, - y: localPoint.y + pathOffset.y, + x: transformedPoint.x + pathOffset.x, + y: transformedPoint.y + pathOffset.y, } - // 단순하고 안정적인 point-in-polygon 알고리즘 사용 - return this.simplePointInPolygon(finalPoint, this.get('points')) - }, - - simplePointInPolygon: function (point, polygon) { - const x = point.x - const y = point.y - let inside = false - - for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) { - const xi = polygon[i].x - const yi = polygon[i].y - const xj = polygon[j].x - const yj = polygon[j].y - - if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) { - inside = !inside - } - } - - return inside - }, - - isPointInPolygonRobust: function (point, polygon) { - const x = point.x - const y = point.y - let inside = false - - // 부동소수점 정밀도를 고려한 허용 오차 - const epsilon = 1e-10 - - for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) { - const xi = polygon[i].x - const yi = polygon[i].y - const xj = polygon[j].x - const yj = polygon[j].y - - // 점이 정점 위에 있는지 확인 (확장된 허용 오차) - if (Math.abs(xi - x) < 0.5 && Math.abs(yi - y) < 0.5) { - return true - } - - // 점이 선분 위에 있는지 확인 - if (this.isPointOnLineSegment(point, { x: xi, y: yi }, { x: xj, y: yj })) { - return true - } - - // Ray casting 알고리즘 - 개선된 버전 - if (Math.abs(yi - yj) > epsilon) { - const minY = Math.min(yi, yj) - const maxY = Math.max(yi, yj) - - if (y > minY && y <= maxY) { - // 교차점 계산 - const intersectionX = xi + ((y - yi) / (yj - yi)) * (xj - xi) - if (intersectionX > x) { - inside = !inside - } - } - } - } - - return inside - }, - - isPointOnLineSegment: function (point, lineStart, lineEnd) { - const tolerance = 2.0 // 더 큰 허용 오차 - const x = point.x - const y = point.y - const x1 = lineStart.x - const y1 = lineStart.y - const x2 = lineEnd.x - const y2 = lineEnd.y - - // 선분의 길이가 0인 경우 (점) - if (Math.abs(x2 - x1) < 1e-10 && Math.abs(y2 - y1) < 1e-10) { - return Math.abs(x - x1) < tolerance && Math.abs(y - y1) < tolerance - } - - // 점과 선분 사이의 거리 계산 - const A = x - x1 - const B = y - y1 - const C = x2 - x1 - const D = y2 - y1 - - const dot = A * C + B * D - const lenSq = C * C + D * D - const param = dot / lenSq - - let xx, yy - - if (param < 0 || (x1 === x2 && y1 === y2)) { - xx = x1 - yy = y1 - } else if (param > 1) { - xx = x2 - yy = y2 + if (this.name === POLYGON_TYPE.ROOF && this.isFixed) { + const isInside = this.inPolygonImproved(finalPoint) + this.set('selectable', isInside) + return isInside } else { - xx = x1 + param * C - yy = y1 + param * D + return this.inPolygonImproved(finalPoint) } - - const dx = x - xx - const dy = y - yy - const distance = Math.sqrt(dx * dx + dy * dy) - - return distance < tolerance }, inPolygonABType(x, y, polygon) { From 9f7fedab799f3bb0f8864eb784aa074fccd76c08 Mon Sep 17 00:00:00 2001 From: ysCha Date: Fri, 11 Jul 2025 15:59:30 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[1182]=20=EC=B6=94=EA=B0=80=20=EA=B2=AC?= =?UTF-8?q?=EC=A0=81=20=EC=B6=9C=EB=A0=A5=20=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20POPUP=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/floor-plan/FloorPlanProvider.js | 2 ++ src/components/estimate/Estimate.jsx | 3 ++- .../estimate/useEstimateController.js | 25 ++++++++++++++++++- src/locales/ja.json | 7 +++--- src/locales/ko.json | 1 + 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/app/floor-plan/FloorPlanProvider.js b/src/app/floor-plan/FloorPlanProvider.js index 1e5c536d..a9595aa5 100644 --- a/src/app/floor-plan/FloorPlanProvider.js +++ b/src/app/floor-plan/FloorPlanProvider.js @@ -21,6 +21,8 @@ const defaultEstimateData = { fileList: [], fileFlg: '0', //후일 자료 제출 (체크 1 노체크 0) priceCd: '', + pricingFlag: false, // 가격 처리 플래그 추가 + } /** diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 9a3dd74d..2fe098cf 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -507,6 +507,7 @@ export default function Estimate({}) { icon: 'warning', confirmFn: () => { handlePricing(showPriceCd) + setEstimateContextState({ pricingFlag:true }) }, }) } @@ -1437,7 +1438,7 @@ export default function Estimate({}) { onChange={(e) => { //주문분류 setHandlePricingFlag(true) - setEstimateContextState({ estimateType: e.target.value }) + setEstimateContextState({ estimateType: e.target.value, setEstimateContextState }) }} /> diff --git a/src/hooks/floorPlan/estimate/useEstimateController.js b/src/hooks/floorPlan/estimate/useEstimateController.js index 9acb79f7..4cbe4521 100644 --- a/src/hooks/floorPlan/estimate/useEstimateController.js +++ b/src/hooks/floorPlan/estimate/useEstimateController.js @@ -167,13 +167,34 @@ export const useEstimateController = (planNo, flag) => { }) } - //견적서 저장 + const handleEstimateSubmit = async () => { + if(estimateContextState.pricingFlag) { + await handleEstimateSubmitCore(); + }else { + swalFire({ + text: getMessage('estimate.detail.save.pricingFlag'), + type: 'confirm', + icon: 'warning', + confirmFn: async () => { + await handleEstimateSubmitCore(); + + }, + denyFn: () => false + }) + return false + } + } + //견적서 저장 + const handleEstimateSubmitCore = async () => { //0. 필수체크 let flag = true let originFileFlg = false let fileFlg = true let itemFlg = true + + + if (estimateData?.charger === null || estimateData?.charger?.trim().length === 0) { flag = false setIsGlobalLoading(false) @@ -355,6 +376,8 @@ export const useEstimateController = (planNo, flag) => { } const realSave = async (fileList) => { + + setEstimateContextState({pricingFlag: false}) //첨부파일저장끝 let option = [] diff --git a/src/locales/ja.json b/src/locales/ja.json index ed372e18..5cd08828 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -993,10 +993,10 @@ "estimate.detail.docPopup.title": "見積書出力オプションの設定", "estimate.detail.docPopup.explane": "ダウンロードする文書オプションを選択し、[見積書出力]ボタンをクリックします。", "estimate.detail.docPopup.schUnitPriceFlg": "ダウンロードファイル", - "estimate.detail.docPopup.schUnitPriceFlg.excelFlg0": "仕切用Excel", + "estimate.detail.docPopup.schUnitPriceFlg.excelFlg0": "見積書Excel", "estimate.detail.docPopup.schUnitPriceFlg.excelFlg1": "定価用Excel", - "estimate.detail.docPopup.schUnitPriceFlg.excelFlg2": "見積書", - "estimate.detail.docPopup.schUnitPriceFlg.pdfFlg0": "仕切用PDF", + "estimate.detail.docPopup.schUnitPriceFlg.excelFlg2": "旧見積書書式", + "estimate.detail.docPopup.schUnitPriceFlg.pdfFlg0": "見積書PDF", "estimate.detail.docPopup.schUnitPriceFlg.pdfFlg1": "定価用PDF", "estimate.detail.docPopup.schDisplayFlg": "見積提出書の表示名", "estimate.detail.docPopup.schDisplayFlg.schDisplayFlg0": "販売店名", @@ -1034,6 +1034,7 @@ "estimate.detail.save.requiredItemId": "製品を選択してください。", "estimate.detail.save.requiredAmount": "数量は0より大きい値を入力してください。", "estimate.detail.save.requiredSalePrice": "単価は0より大きい値を入力してください。", + "estimate.detail.save.pricingFlag": "設定した価格見積が作成されます。このまま進めてよろしいですか?", "estimate.detail.reset.alertMsg": "初期化されました。", "estimate.detail.reset.confirmMsg": "保存した見積情報が初期化され、最近保存された図面情報が反映されます。本当に初期化しますか?", "estimate.detail.lock.alertMsg": "見積もりを[ロック]すると変更できません。
見積もりを修正するには、ロックを解除してください。", diff --git a/src/locales/ko.json b/src/locales/ko.json index c0cd43af..19864ac4 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -1034,6 +1034,7 @@ "estimate.detail.save.requiredItemId": "제품을 선택해주세요.", "estimate.detail.save.requiredAmount": "수량은 0보다 큰값을 입력해주세요.", "estimate.detail.save.requiredSalePrice": "단가는 0보다 큰값을 입력해주세요.", + "estimate.detail.save.pricingFlag": "설정한 가격 견적이 작성됩니다. 이대로 진행해도 괜찮으시겠습니까?", "estimate.detail.reset.alertMsg": "초기화 되었습니다.", "estimate.detail.reset.confirmMsg": "수기 변경(저장)한 견적 정보가 초기화되고 최근 저장된 도면정보가 반영됩니다. 정말로 초기화하시겠습니까?", "estimate.detail.lock.alertMsg": "견적서를 [잠금]하면 수정할 수 없습니다.
견적서를 수정하려면 잠금해제를 하십시오.",