Merge branch 'qcast-pub' into dev
This commit is contained in:
commit
88f12233f1
@ -409,7 +409,8 @@ export default function CanvasMenu(props) {
|
|||||||
return (
|
return (
|
||||||
(['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.type === 'outline') ||
|
(['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.type === 'outline') ||
|
||||||
(selectedMenu === 'module' && ['drawing', 'placement'].includes(menu.type)) ||
|
(selectedMenu === 'module' && ['drawing', 'placement'].includes(menu.type)) ||
|
||||||
(isExistModule() && ['placement', 'outline'].some((num) => num === menu.type))
|
(isExistModule() && ['placement', 'outline'].some((num) => num === menu.type)) ||
|
||||||
|
(['estimate', 'simulation'].includes(selectedMenu) && ['drawing', 'placement', 'outline', 'surface'].includes(menu.type))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,9 +534,7 @@ export default function CanvasMenu(props) {
|
|||||||
key={`canvas-menu-${menu.type}`}
|
key={`canvas-menu-${menu.type}`}
|
||||||
className={`canvas-menu-item ${selectedMenu === menu.type ? 'active' : ''}`}
|
className={`canvas-menu-item ${selectedMenu === menu.type ? 'active' : ''}`}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.type === 'outline') return
|
if (checkMenuState(menu)) return
|
||||||
if (selectedMenu === 'module' && ['drawing', 'placement'].includes(menu.type)) return
|
|
||||||
if (isExistModule() && ['placement', 'outline'].some((num) => num === menu.type)) return
|
|
||||||
await onClickNav(menu)
|
await onClickNav(menu)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -7,6 +7,9 @@ import { contextPopupPositionState } from '@/store/popupAtom'
|
|||||||
import QSelectBox from '@/components/common/select/QSelectBox'
|
import QSelectBox from '@/components/common/select/QSelectBox'
|
||||||
import { canvasState, pitchTextSelector } from '@/store/canvasAtom'
|
import { canvasState, pitchTextSelector } from '@/store/canvasAtom'
|
||||||
import { defaultSlope } from '@/store/commonAtom'
|
import { defaultSlope } from '@/store/commonAtom'
|
||||||
|
import { re } from 'mathjs'
|
||||||
|
import { basicSettingState } from '@/store/settingAtom'
|
||||||
|
import { getChonByDegree } from '@/util/canvas-util'
|
||||||
|
|
||||||
export default function DimensionLineSetting(props) {
|
export default function DimensionLineSetting(props) {
|
||||||
const contextPopupPosition = useRecoilValue(contextPopupPositionState)
|
const contextPopupPosition = useRecoilValue(contextPopupPositionState)
|
||||||
@ -18,7 +21,11 @@ export default function DimensionLineSetting(props) {
|
|||||||
const SelectOption01 = defaultSlope
|
const SelectOption01 = defaultSlope
|
||||||
const [basicLength, setBasicLength] = useState(0)
|
const [basicLength, setBasicLength] = useState(0)
|
||||||
const [slopeAble, setSlopeAble] = useState(false)
|
const [slopeAble, setSlopeAble] = useState(false)
|
||||||
|
const basicSetting = useRecoilValue(basicSettingState)
|
||||||
const changeSlopeRef = useRef()
|
const changeSlopeRef = useRef()
|
||||||
|
const [options, setOptions] = useState([])
|
||||||
|
const [selectedSlope1, setSelectedSlope1] = useState(null)
|
||||||
|
const [selectedSlope2, setSelectedSlope2] = useState(null)
|
||||||
|
|
||||||
let slopeInput1, slopeInput2
|
let slopeInput1, slopeInput2
|
||||||
|
|
||||||
@ -26,10 +33,30 @@ export default function DimensionLineSetting(props) {
|
|||||||
if (canvas) {
|
if (canvas) {
|
||||||
const dimensionObject = canvas.getActiveObject()
|
const dimensionObject = canvas.getActiveObject()
|
||||||
const id = dimensionObject.groupId
|
const id = dimensionObject.groupId
|
||||||
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.id === id)[0]
|
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0]
|
||||||
|
if (!textObj) return
|
||||||
setBasicLength(parseInt(textObj.text))
|
setBasicLength(parseInt(textObj.text))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (basicSetting.roofAngleSet === 'slope') {
|
||||||
|
setOptions(
|
||||||
|
Array.from({ length: 21 }).map((_, index) => {
|
||||||
|
return {
|
||||||
|
name: index * 0.5,
|
||||||
|
value: index * 0.5,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
setOptions(
|
||||||
|
Array.from({ length: 7 }).map((_, index) => {
|
||||||
|
return {
|
||||||
|
name: index * 5,
|
||||||
|
value: index * 5,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
return () => {
|
return () => {
|
||||||
setBasicLength(0)
|
setBasicLength(0)
|
||||||
}
|
}
|
||||||
@ -41,45 +68,40 @@ export default function DimensionLineSetting(props) {
|
|||||||
if (canvas) {
|
if (canvas) {
|
||||||
const dimensionObject = canvas.getActiveObject()
|
const dimensionObject = canvas.getActiveObject()
|
||||||
const id = dimensionObject.groupId
|
const id = dimensionObject.groupId
|
||||||
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.id === id)[0]
|
const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0]
|
||||||
let resultText = changeLength.value > 0 ? changeLength.value : '0'
|
let resultText = changeLength.value > 0 ? changeLength.value : '0'
|
||||||
|
|
||||||
if (slopeAble) {
|
if (slopeAble) {
|
||||||
if (slopeInput1) {
|
resultText = !selectedSlope2
|
||||||
resultText = calculateLength(basicLength, slopeInput1.angleValue).toFixed(0)
|
? calculateLength(basicLength, selectedSlope1.value).toFixed(0)
|
||||||
|
: calculateLength(basicLength, selectedSlope1.value, selectedSlope2.value).toFixed(0)
|
||||||
if (slopeInput2) {
|
|
||||||
const length = calculateLength(basicLength, slopeInput1.angleValue, slopeInput2.angleValue)
|
|
||||||
resultText = length.toFixed(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
textObj.set({
|
textObj.set({
|
||||||
text: String(resultText),
|
text: String(resultText),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
setBasicLength(resultText)
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSelectbox = (option, params) => {
|
function calculateLength(originalLength, angle, angle1) {
|
||||||
const index = params.index
|
console.log(angle, angle1)
|
||||||
if (index === 1) slopeInput1 = option
|
const slope1 = basicSetting.roofAngleSet !== 'slope' ? getChonByDegree(angle) : angle
|
||||||
if (index === 2) slopeInput2 = option
|
const slope2 = basicSetting.roofAngleSet !== 'slope' ? getChonByDegree(angle1 ?? 0) : angle1
|
||||||
}
|
if (!angle1) {
|
||||||
|
const angleInRadians = slope1 * (Math.PI / 180)
|
||||||
function calculateLength(originalLength, angle) {
|
const result = Math.sqrt(Math.pow(originalLength * Math.tan(angleInRadians), 2) + Math.pow(originalLength, 2))
|
||||||
const angleInRadians = angle * (Math.PI / 180)
|
console.log(angleInRadians, result)
|
||||||
const result = Math.sqrt(Math.pow(originalLength * Math.tan(angleInRadians), 2) + Math.pow(originalLength, 2))
|
return result
|
||||||
return result
|
} else {
|
||||||
}
|
const numerator = Math.sqrt(Math.pow(slope1, 2) + 100 + Math.pow((10 * slope1) / slope2, 2)) * originalLength
|
||||||
|
const denominator = Math.sqrt(Math.pow((10 * slope1) / slope2, 2) + 100)
|
||||||
function calculateLength(originalLength, angle1, angle2) {
|
const result = numerator / denominator
|
||||||
const numerator = Math.sqrt(Math.pow(angle1, 2) + 100 + Math.pow((10 * angle1) / angle2, 2)) * originalLength
|
console.log('2222222222222222')
|
||||||
const denominator = Math.sqrt(Math.pow((10 * angle1) / angle2, 2) + 100)
|
return result
|
||||||
const result = numerator / denominator
|
}
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -123,14 +145,32 @@ export default function DimensionLineSetting(props) {
|
|||||||
<div className="outline-form mb15">
|
<div className="outline-form mb15">
|
||||||
<span className="mr10">{getMessage('slope')}</span>
|
<span className="mr10">{getMessage('slope')}</span>
|
||||||
<div className="grid-select mr10">
|
<div className="grid-select mr10">
|
||||||
<QSelectBox title={''} options={SelectOption01} disabled={!slopeAble} params={{ index: 1 }} onChange={handleSelectbox} />
|
<QSelectBox
|
||||||
|
title={''}
|
||||||
|
options={options}
|
||||||
|
disabled={!slopeAble}
|
||||||
|
value={selectedSlope1}
|
||||||
|
onChange={(e) => setSelectedSlope1(e)}
|
||||||
|
showKey={'name'}
|
||||||
|
sourceKey={'value'}
|
||||||
|
targetKey={'value'}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span className="thin">{pitchText}</span>
|
<span className="thin">{pitchText}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="outline-form">
|
<div className="outline-form">
|
||||||
<span className="mr10">{getMessage('slope')}</span>
|
<span className="mr10">{getMessage('slope')}</span>
|
||||||
<div className="grid-select mr10">
|
<div className="grid-select mr10">
|
||||||
<QSelectBox title={''} options={SelectOption01} disabled={!slopeAble} params={{ index: 2 }} onChange={handleSelectbox} />
|
<QSelectBox
|
||||||
|
title={''}
|
||||||
|
options={options}
|
||||||
|
disabled={!slopeAble}
|
||||||
|
value={selectedSlope2}
|
||||||
|
onChange={(e) => setSelectedSlope2(e)}
|
||||||
|
showKey={'name'}
|
||||||
|
sourceKey={'value'}
|
||||||
|
targetKey={'value'}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span className="thin">{pitchText}</span>
|
<span className="thin">{pitchText}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -129,6 +129,7 @@ export function useAuxiliaryDrawing(id, isUseEffect = true) {
|
|||||||
|
|
||||||
const copy = (object, x, y) => {
|
const copy = (object, x, y) => {
|
||||||
return addLine([object.x1 + x, object.y1 + y, object.x2 + x, object.y2 + y], {
|
return addLine([object.x1 + x, object.y1 + y, object.x2 + x, object.y2 + y], {
|
||||||
|
attributes: object.attributes,
|
||||||
stroke: 'red',
|
stroke: 'red',
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
selectable: true,
|
selectable: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user