diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index acc2aab1..5730f574 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -41,9 +41,6 @@ export const useTrestle = () => { const direction = parent.direction const rack = surface.trestleDetail.rack let { rackQty, rackIntvlPct, rackYn, cvrPlvrYn } = surface.trestleDetail - // rackYn = 'N' - // rackQty = 5 - cvrPlvrYn = 'Y' if (!rack) { //25/01/16 기준 랙이 없는 경우는 그냥 안그려준다. @@ -95,6 +92,8 @@ export const useTrestle = () => { leftExposedHalfTopModules.length > 0 || rightExposedHalfTopPoints.length > 0 + surface.set({ isChidory: isChidory }) + canvas .getObjects() .filter((obj) => ['eaveBar', 'halfEaveBar'].includes(obj.name) && obj.parent === surface) @@ -1005,8 +1004,8 @@ export const useTrestle = () => { const installBracketWithOutRack = (surface, exposedBottomModules, leftExposedHalfBottomModules, rightExposedHalfBottomPoints, isChidory) => { let { rackQty, rackIntvlPct, moduleIntvlHor, moduleIntvlVer, lessSupFitQty, lessSupFitIntvlPct } = surface.trestleDetail const direction = surface.direction - rackQty = lessSupFitQty - rackIntvlPct = lessSupFitIntvlPct + rackQty = 3 + rackIntvlPct = 10 canvas.renderAll() exposedBottomModules.forEach((module) => { @@ -1517,7 +1516,7 @@ export const useTrestle = () => { eavesTotCnt: eaveBar.length, eavesHalfTotCnt: halfEaveBar.length, racks: rackParams, - rackTotCnt: rackList.length + smartRackGroup.length, + rackTotCnt: rackList.length ?? 0 + smartRackGroup.length ?? 0, rackFittingCnt: bracketList.length, moduleRows: getMostLeftModules(surface), } @@ -1532,7 +1531,7 @@ export const useTrestle = () => { let isEaveBar = construction.setupCover let isSnowGuard = construction.setupSnowCover let { rackYn, cvrPlvrYn, moduleIntvlHor, moduleIntvlVer, rackQty, lessSupFitQty } = surface.trestleDetail - cvrPlvrYn = 'Y' + if (rackYn === 'N') { rackQty = lessSupFitQty } @@ -1619,30 +1618,48 @@ export const useTrestle = () => { // 모듈 하면,최하면 등 구해야함 modules.forEach((module, index) => { // 해당 모듈 주변에 다른 모듈이 있는지 확인 - let { bottomModule, topModule, bottomLeftModule, bottomRightModule, topLeftModule, topRightModule } = findSideModule(module, surface) + let { + bottomModule, + topModule, + halfBottomLeftModule, + halfBottomRightModule, + halfTopLeftModule, + halfTopRightModule, + leftModule, + rightModule, + bottomLeftModule, + bottomRightModule, + } = findSideModule(module, surface) if (bottomModule) { moduleRowResultData.touchedSurfaceCnt++ } if (!bottomModule) { - if (bottomLeftModule && bottomRightModule) { + if (halfBottomLeftModule && halfBottomRightModule) { moduleRowResultData.touchedSurfaceCnt++ - } else if ((bottomLeftModule && !bottomRightModule) || (!bottomLeftModule && bottomRightModule)) { + } else if ((halfBottomLeftModule && !halfBottomRightModule) || (!halfBottomLeftModule && halfBottomRightModule)) { moduleRowResultData.touchedHalfSurfaceCnt++ moduleRowResultData.exposedHalfBottomCnt++ if (cvrPlvrYn === 'Y') { moduleRowResultData.eavesHalfCnt++ + if (bottomLeftModule || bottomRightModule || halfBottomLeftModule || halfBottomRightModule) { + moduleRowResultData.exposedSideEavesCnt++ + } } } else { moduleRowResultData.exposedBottomCnt++ if (isEaveBar) { moduleRowResultData.eavesCnt++ } + + if (!(leftModule && rightModule)) { + moduleRowResultData.exposedSideEavesCnt++ + } } } if (!topModule) { - if ((topLeftModule && !topRightModule) || (!topLeftModule && topRightModule)) { + if ((halfTopLeftModule && !halfTopRightModule) || (!halfTopLeftModule && halfTopRightModule)) { moduleRowResultData.exposedHalfTopCnt++ - } else if (!topLeftModule && !topRightModule) { + } else if (!halfTopLeftModule && !halfTopRightModule) { moduleRowResultData.exposedTopCnt++ } } @@ -1651,9 +1668,6 @@ export const useTrestle = () => { result.push(moduleRowResultData) }) - if (isEaveBar) { - } - return result } @@ -1674,73 +1688,116 @@ export const useTrestle = () => { let { width, height } = { ...module } let { x, y } = { ...module.getCenterPoint() } + let halfBottomLeftPoint + let halfBottomRightPoint + let halfTopLeftPoint + let halfTopRightPoint + let leftPoint + let rightPoint let bottomLeftPoint let bottomRightPoint - let topLeftPoint - let topRightPoint let bottomModule let topModule + let halfBottomLeftModule + let halfBottomRightModule + let halfTopLeftModule + let halfTopRightModule + let leftModule + let rightModule let bottomLeftModule let bottomRightModule - let topLeftModule - let topRightModule switch (direction) { case 'south': width = width + horizontal height = height + vertical bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY) - bottomLeftPoint = { x: x - width / 2, y: y + height } - bottomRightPoint = { x: x + width / 2, y: y + height } + halfBottomLeftPoint = { x: x - width / 2, y: y + height } + halfBottomRightPoint = { x: x + width / 2, y: y + height } topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY) - topLeftPoint = { x: x - width / 2, y: y - height } - topRightPoint = { x: x + width / 2, y: y - height } + halfTopLeftPoint = { x: x - width / 2, y: y - height } + halfTopRightPoint = { x: x + width / 2, y: y - height } + leftPoint = { x: x - width, y: y } + rightPoint = { x: x + width, y: y } + bottomLeftModule = { x: x - width, y: y + height } + bottomRightModule = { x: x + width, y: y + height } break case 'north': width = width + horizontal height = height + vertical bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY) - bottomLeftPoint = { x: x + width / 2, y: y - height } - bottomRightPoint = { x: x - width / 2, y: y - height } + halfBottomLeftPoint = { x: x + width / 2, y: y - height } + halfBottomRightPoint = { x: x - width / 2, y: y - height } topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY) - topLeftPoint = { x: x + width / 2, y: y + height } - topRightPoint = { x: x - width / 2, y: y + height } + halfTopLeftPoint = { x: x + width / 2, y: y + height } + halfTopRightPoint = { x: x - width / 2, y: y + height } + leftPoint = { x: x + width, y: y } + rightPoint = { x: x - width, y: y } + bottomLeftModule = { x: x + width, y: y - height } + bottomRightModule = { x: x - width, y: y - height } break case 'east': bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY) width = width + horizontal - bottomLeftPoint = { x: x + width, y: y + height / 2 } - bottomRightPoint = { x: x + width, y: y - height / 2 } + halfBottomLeftPoint = { x: x + width, y: y + height / 2 } + halfBottomRightPoint = { x: x + width, y: y - height / 2 } topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY) - topLeftPoint = { x: x - width, y: y + height / 2 } - topRightPoint = { x: x - width, y: y - height / 2 } + halfTopLeftPoint = { x: x - width, y: y + height / 2 } + halfTopRightPoint = { x: x - width, y: y - height / 2 } + leftPoint = { x: x, y: y + height } + rightPoint = { x: x, y: y - height } + bottomLeftModule = { x: x + width, y: y + height } + bottomRightModule = { x: x + width, y: y - height } break case 'west': bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY) width = width + horizontal - bottomLeftPoint = { x: x - width, y: y - height / 2 } - bottomRightPoint = { x: x - width, y: y + height / 2 } - topLeftPoint = { x: x + width, y: y - height / 2 } - topRightPoint = { x: x + width, y: y + height / 2 } + halfBottomLeftPoint = { x: x - width, y: y - height / 2 } + halfBottomRightPoint = { x: x - width, y: y + height / 2 } topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY) + halfTopLeftPoint = { x: x + width, y: y - height / 2 } + halfTopRightPoint = { x: x + width, y: y + height / 2 } + leftPoint = { x: x, y: y - height } + rightPoint = { x: x, y: y + height } + bottomLeftModule = { x: x - width, y: y - height } + bottomRightModule = { x: x - width, y: y + height } break } - topLeftModule = centerPoints.find( - (centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY, + halfTopLeftModule = centerPoints.find( + (centerPoint) => Math.abs(centerPoint.x - halfTopLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfTopLeftPoint.y) < maxY, ) - topRightModule = centerPoints.find( - (centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY, + halfTopRightModule = centerPoints.find( + (centerPoint) => Math.abs(centerPoint.x - halfTopRightPoint.x) < maxX && Math.abs(centerPoint.y - halfTopRightPoint.y) < maxY, ) + halfBottomLeftModule = centerPoints.find( + (centerPoint) => Math.abs(centerPoint.x - halfBottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomLeftPoint.y) < maxY, + ) + halfBottomRightModule = centerPoints.find( + (centerPoint) => Math.abs(centerPoint.x - halfBottomRightPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomRightPoint.y) < maxY, + ) + leftModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - leftPoint.x) < maxX && Math.abs(centerPoint.y - leftPoint.y) < maxY) + rightModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - rightPoint.x) < maxX && Math.abs(centerPoint.y - rightPoint.y) < maxY) bottomLeftModule = centerPoints.find( - (centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY, + (centerPoint) => Math.abs(centerPoint.x - bottomLeftModule.x) < maxX && Math.abs(centerPoint.y - bottomLeftModule.y) < maxY, ) bottomRightModule = centerPoints.find( - (centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY, + (centerPoint) => Math.abs(centerPoint.x - bottomRightModule.x) < maxX && Math.abs(centerPoint.y - bottomRightModule.y) < maxY, ) - return { bottomModule, topModule, bottomLeftModule, bottomRightModule, topLeftModule, topRightModule } + return { + bottomModule, + topModule, + halfBottomLeftModule, + halfBottomRightModule, + halfTopLeftModule, + halfTopRightModule, + leftModule, + rightModule, + bottomLeftModule, + bottomRightModule, + } } return { apply, getTrestleParams }