dev #561

Merged
ysCha merged 7 commits from dev into prd-deploy 2026-01-08 15:19:12 +09:00
8 changed files with 104 additions and 35 deletions

View File

@ -340,13 +340,19 @@ export const CalculatorInput = forwardRef(
// Tab // Tab
if (e.key === 'Tab') { if (e.key === 'Tab') {
if (hasOperation) {
handleCompute(true) //
}
setShowKeypad(false) setShowKeypad(false)
return return
} }
// //
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight' || e.key === 'ArrowUp' || e.key === 'ArrowDown') { if (e.key === 'ArrowLeft' || e.key === 'ArrowRight' || e.key === 'ArrowUp' || e.key === 'ArrowDown') {
setShowKeypad(true) if (hasOperation) {
handleCompute(true) //
}
setShowKeypad(false)
return return
} }
@ -360,6 +366,12 @@ export const CalculatorInput = forwardRef(
return return
} }
// --- ---
if (e.key !== 'Process') { // ()
// e.preventDefault() .
}
e.preventDefault() e.preventDefault()
const calculator = calculatorRef.current const calculator = calculatorRef.current
const { allowDecimal } = options const { allowDecimal } = options

View File

@ -72,13 +72,17 @@ export const QLine = fabric.util.createClass(fabric.Line, {
setLength() { setLength() {
// Ensure all required properties are valid numbers // Ensure all required properties are valid numbers
const { x1, y1, x2, y2 } = this; const { x1, y1, x2, y2 } = this
if (isNaN(x1) || isNaN(y1) || isNaN(x2) || isNaN(y2)) { if (isNaN(x1) || isNaN(y1) || isNaN(x2) || isNaN(y2)) {
logger.error('Invalid coordinates in QLine:', { x1, y1, x2, y2 }); logger.error('Invalid coordinates in QLine:', { x1, y1, x2, y2 })
this.length = 0; this.length = 0
return; return
} }
this.length = calcLinePlaneSize({ x1, y1, x2, y2 }) / 10; this.length = calcLinePlaneSize({ x1, y1, x2, y2 }) / 10
},
setLengthByValue(length) {
this.length = length / 10
}, },
addLengthText() { addLengthText() {

View File

@ -123,10 +123,14 @@ export default function PassivityCircuitAllocation(props) {
} }
// targetModule Y N . // targetModule Y N .
const targetModuleGroup = [...new Set(canvas const targetModuleGroup = [
.getObjects() ...new Set(
.filter((obj) => obj.name === POLYGON_TYPE.MODULE && targetModules.includes(obj.id)) canvas
.map((obj) => obj.moduleInfo.northModuleYn))] .getObjects()
.filter((obj) => obj.name === POLYGON_TYPE.MODULE && targetModules.includes(obj.id))
.map((obj) => obj.moduleInfo.northModuleYn),
),
]
if (targetModuleGroup.length > 1) { if (targetModuleGroup.length > 1) {
swalFire({ swalFire({
@ -142,16 +146,12 @@ export default function PassivityCircuitAllocation(props) {
const originHaveThisPcsModules = canvas const originHaveThisPcsModules = canvas
.getObjects() .getObjects()
.filter((obj) => obj.name === POLYGON_TYPE.MODULE && obj.pcs && obj.pcs.id === selectedPcs.id) .filter((obj) => obj.name === POLYGON_TYPE.MODULE && obj.pcs && obj.pcs.id === selectedPcs.id)
// pcs surface . // 1. ,
const originSurfaceList = canvas const targetModuleInfos = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE && targetModules.includes(obj.id))
.getObjects() debugger
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && originHaveThisPcsModules.map((obj) => obj.surfaceId).includes(obj.id)) const newTargetModuleGroup = [...new Set(targetModuleInfos.concat(originHaveThisPcsModules).map((obj) => obj.moduleInfo.northModuleYn))]
originSurfaceList.concat(originSurfaceList).forEach((surface) => { if (newTargetModuleGroup.length > 1) {
surfaceType[`${surface.direction}-${surface.roofMaterial.pitch}`] = surface
})
if (Object.keys(surfaceType).length > 1) {
swalFire({ swalFire({
text: getMessage('module.circuit.fix.not.same.roof.error'), text: getMessage('module.circuit.fix.not.same.roof.error'),
type: 'alert', type: 'alert',
@ -234,7 +234,6 @@ export default function PassivityCircuitAllocation(props) {
setSelectedPcs(tempSelectedPcs) setSelectedPcs(tempSelectedPcs)
canvas.add(moduleCircuitText) canvas.add(moduleCircuitText)
}) })
const roofSurfaceList = canvas const roofSurfaceList = canvas
.getObjects() .getObjects()

View File

@ -26,17 +26,15 @@ export default function DoublePitch({ props }) {
arrow2Ref, arrow2Ref,
} = props } = props
const getLength2 = () => { const getLength2 = (angle1, angle2, length1) => {
const angle1Value = angle1Ref.current.value const angle1Value = angle1 !== undefined ? angle1 : angle1Ref.current?.value
const angle2Value = angle2Ref.current.value const angle2Value = angle2 !== undefined ? angle2 : angle2Ref.current?.value
const length1Value = length1Ref.current.value const length1Value = length1 !== undefined ? length1 : length1Ref.current?.value
const arrow1Value = arrow1Ref.current const arrow1Value = arrow1Ref.current
const arrow2Value = arrow2Ref.current
if (angle1Value !== 0 && length1Value !== 0 && angle2Value !== 0 && arrow1Value !== '') { if (!isNaN(Number(angle1Value)) && !isNaN(Number(length1Value)) && !isNaN(Number(angle2Value)) && arrow1Value) {
const radian1 = (getDegreeByChon(angle1Value) * Math.PI) / 180 const radian1 = (getDegreeByChon(angle1Value) * Math.PI) / 180
const radian2 = (getDegreeByChon(angle2Value) * Math.PI) / 180 const radian2 = (getDegreeByChon(angle2Value) * Math.PI) / 180
return Math.floor((Math.tan(radian1) * length1Value) / Math.tan(radian2)) return Math.floor((Math.tan(radian1) * length1Value) / Math.tan(radian2))
} }
@ -178,7 +176,7 @@ export default function DoublePitch({ props }) {
ref={angle2Ref} ref={angle2Ref}
onChange={(value) => { onChange={(value) => {
setAngle2(value) setAngle2(value)
setLength2(getLength2()) setLength2(getLength2(angle1Ref.current?.value, value, length1Ref.current?.value))
}} }}
placeholder="45" placeholder="45"
onFocus={() => (angle2Ref.current.value = '')} onFocus={() => (angle2Ref.current.value = '')}

View File

@ -10,7 +10,7 @@ import {
} from '@/store/canvasAtom' } from '@/store/canvasAtom'
import { QLine } from '@/components/fabric/QLine' import { QLine } from '@/components/fabric/QLine'
import { basicSettingState } from '@/store/settingAtom' import { basicSettingState } from '@/store/settingAtom'
import { calcLineActualSize } from '@/util/qpolygon-utils' import { calcLineActualSizeByLineLength } from '@/util/qpolygon-utils'
import { getDegreeByChon } from '@/util/canvas-util' import { getDegreeByChon } from '@/util/canvas-util'
import { useText } from '@/hooks/useText' import { useText } from '@/hooks/useText'
import { fontSelector } from '@/store/fontAtom' import { fontSelector } from '@/store/fontAtom'
@ -181,7 +181,7 @@ export const useLine = () => {
if (isVertical) { if (isVertical) {
line.attributes = { line.attributes = {
...line.attributes, ...line.attributes,
actualSize: calcLineActualSize(line, getDegreeByChon(pitch)), actualSize: calcLineActualSizeByLineLength(lineLength, getDegreeByChon(pitch)),
} }
} else if (isDiagonal) { } else if (isDiagonal) {
const yLength = Math.abs(y2 - y1) * 10 const yLength = Math.abs(y2 - y1) * 10
@ -195,7 +195,7 @@ export const useLine = () => {
if (isHorizontal) { if (isHorizontal) {
line.attributes = { line.attributes = {
...line.attributes, ...line.attributes,
actualSize: calcLineActualSize(line, getDegreeByChon(pitch)), actualSize: calcLineActualSizeByLineLength(lineLength, getDegreeByChon(pitch)),
} }
} else if (isDiagonal) { } else if (isDiagonal) {
const xLength = Math.abs(x2 - x1) * 10 const xLength = Math.abs(x2 - x1) * 10

View File

@ -1,7 +1,19 @@
import { ANGLE_TYPE, canvasState, currentAngleTypeSelector, globalPitchState, pitchTextSelector } from '@/store/canvasAtom' import {
ANGLE_TYPE,
canvasState,
currentAngleTypeSelector,
globalPitchState,
pitchTextSelector,
} from '@/store/canvasAtom'
import { useRecoilValue } from 'recoil' import { useRecoilValue } from 'recoil'
import { fabric } from 'fabric' import { fabric } from 'fabric'
import { calculateIntersection, findAndRemoveClosestPoint, getDegreeByChon, getDegreeInOrientation, isPointOnLine } from '@/util/canvas-util' import {
calculateIntersection,
findAndRemoveClosestPoint,
getDegreeByChon,
getDegreeInOrientation,
isPointOnLine,
} from '@/util/canvas-util'
import { QPolygon } from '@/components/fabric/QPolygon' import { QPolygon } from '@/components/fabric/QPolygon'
import { isSamePoint, removeDuplicatePolygons } from '@/util/qpolygon-utils' import { isSamePoint, removeDuplicatePolygons } from '@/util/qpolygon-utils'
import { basicSettingState, flowDisplaySelector } from '@/store/settingAtom' import { basicSettingState, flowDisplaySelector } from '@/store/settingAtom'
@ -1958,6 +1970,38 @@ export const usePolygon = () => {
canvas.renderAll() canvas.renderAll()
} }
/**
* 폴리곤의 라인 길이가 10 이하로 차이나는 경우 작은 값으로 통일
* @param polygon
*/
const unifyLineLengths = (polygon) => {
if (!polygon.lines || polygon.lines.length === 0) {
return
}
const lines = polygon.lines
for (let i = 0; i < lines.length; i++) {
for (let j = i + 1; j < lines.length; j++) {
const length1 = lines[i].getLength()
const length2 = lines[j].getLength()
const diff = Math.abs(length1 - length2)
if (diff > 0 && diff <= 10) {
const minLength = Math.min(length1, length2)
if (length1 > length2) {
lines[i].setLengthByValue(minLength)
} else {
lines[j].setLengthByValue(minLength)
}
}
}
}
addLengthText(polygon)
canvas.renderAll()
}
/** /**
* 폴리곤의 라인 속성을 복도치수, 실제치수에 따라 actualSize 설정 * 폴리곤의 라인 속성을 복도치수, 실제치수에 따라 actualSize 설정
* @param polygon * @param polygon
@ -1966,7 +2010,7 @@ export const usePolygon = () => {
if (!polygon.lines || polygon.lines.length === 0 || !polygon.roofMaterial) { if (!polygon.lines || polygon.lines.length === 0 || !polygon.roofMaterial) {
return return
} }
unifyLineLengths(polygon)
polygon.lines.forEach((line) => { polygon.lines.forEach((line) => {
setActualSize(line, polygon.direction, +polygon.roofMaterial?.pitch) setActualSize(line, polygon.direction, +polygon.roofMaterial?.pitch)
}) })
@ -1983,5 +2027,6 @@ export const usePolygon = () => {
splitPolygonWithLines, splitPolygonWithLines,
splitPolygonWithSeparate, splitPolygonWithSeparate,
setPolygonLinesActualSize, setPolygonLinesActualSize,
unifyLineLengths,
} }
} }

View File

@ -80,7 +80,7 @@ export const getCenterPoint = (point1, point2) => {
* @returns * @returns
*/ */
export const getDistance = (x1, y1, x2, y2) => { export const getDistance = (x1, y1, x2, y2) => {
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)).toFixed(0) return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)).toFixed(1)
} }
// polygon의 각 변에 해당 점과 점 사이의 거리를 나타내는 IText를 추가하는 함수 // polygon의 각 변에 해당 점과 점 사이의 거리를 나타내는 IText를 추가하는 함수

View File

@ -5992,6 +5992,17 @@ export const calcLineActualSize = (points, degree = 0) => {
return Big(planeSize).div(theta).round().toNumber() return Big(planeSize).div(theta).round().toNumber()
} }
/**
* 포인트와 기울기를 기준으로 선의 길이를 구한다.
* @param lineLength
* @param degree
* @returns number
*/
export const calcLineActualSizeByLineLength = (lineLength, degree = 0) => {
const theta = Big(Math.cos(Big(degree).times(Math.PI).div(180)))
return Big(lineLength).div(theta).round().toNumber()
}
export const createLinesFromPolygon = (points) => { export const createLinesFromPolygon = (points) => {
const lines = [] const lines = []
for (let i = 0; i < points.length; i++) { for (let i = 0; i < points.length; i++) {