From 3009b791f64e6f72c5e9530d1a7beaf0cd3efd8a Mon Sep 17 00:00:00 2001 From: sarikaya Date: Thu, 4 Jul 2024 22:11:53 +0300 Subject: [PATCH] Use overall_from_subgrades field for the total robogrades values --- cvat-ui/src/actions/grades-actions.ts | 3 ++ .../grades-form/grades-form.tsx | 43 +++---------------- cvat-ui/src/reducers/grades-reducer.ts | 2 + cvat-ui/src/reducers/interfaces.ts | 2 + 4 files changed, 13 insertions(+), 37 deletions(-) diff --git a/cvat-ui/src/actions/grades-actions.ts b/cvat-ui/src/actions/grades-actions.ts index f825aa710448..1f34e5486c0b 100644 --- a/cvat-ui/src/actions/grades-actions.ts +++ b/cvat-ui/src/actions/grades-actions.ts @@ -133,6 +133,8 @@ export const loadingGradesAsync = front_surface_laser_grade: mapGradeValue(result?.laser_front_scan?.surface_result?.results?.grade), front_overall_predicted_grade: mapGradeValue(result?.laser_front_scan?.overall_predicted_grade), back_overall_predicted_grade: mapGradeValue(result?.laser_back_scan?.overall_predicted_grade), + front_overall_from_subgrades: mapGradeValue(result?.laser_front_scan?.overall_from_subgrades), + back_overall_from_subgrades: mapGradeValue(result?.laser_back_scan?.overall_from_subgrades), front_raw_surface_minor_defect: result?.front_raw_grades?.surface_minor_defect, front_raw_surface_major_defect: result?.front_raw_grades?.surface_major_defect, front_raw_edge_minor_defect: result?.front_raw_grades?.edge_minor_defect, @@ -318,6 +320,7 @@ export const submitAnnotationFrameToGradeAsync = [`${input.orientation}_edges_laser_grade`]: mapGradeValue(data?.edge), [`${input.orientation}_surface_laser_grade`]: mapGradeValue(data?.surface), [`${input.orientation}_overall_predicted_grade`]: mapGradeValue(data?.overall), + [`${input.orientation}_overall_from_subgrades`]: mapGradeValue(data?.overall_from_subgrades), [`${input.orientation}_opposite_angle`]: mapGradeValue(data?.angles?.opposite_angle), [`${input.orientation}_inner_outer_angle`]: mapGradeValue(data?.angles?.inner_outer_angle), [`${input.orientation}_distance`]: mapGradeValue(data?.angles?.distance), diff --git a/cvat-ui/src/components/annotation-page/grades-form/grades-form.tsx b/cvat-ui/src/components/annotation-page/grades-form/grades-form.tsx index 1b2a8f3771ed..513ccd897ada 100644 --- a/cvat-ui/src/components/annotation-page/grades-form/grades-form.tsx +++ b/cvat-ui/src/components/annotation-page/grades-form/grades-form.tsx @@ -54,8 +54,6 @@ export function GradesForm({ task }: Props): JSX.Element | null { const values = useSelector((state: CombinedState) => state.grades.values); const [computedHumanFrontTotal, setComputedHumanFrontTotal] = useState(0); const [computedHumanBackTotal, setComputedHumanBackTotal] = useState(0); - const [computedRobogradesFrontTotal, setComputedRobogradesFrontTotal] = useState(0); - const [computedRobogradesBackTotal, setComputedRobogradesBackTotal] = useState(0); const [computedRawRobogradesFrontTotal, setComputedRawRobogradesFrontTotal] = useState(0); const [computedRawRobogradesBackTotal, setComputedRawRobogradesBackTotal] = useState(0); const [computedLowestTotal, setComputedLowestTotal] = useState(0); @@ -165,22 +163,6 @@ export function GradesForm({ task }: Props): JSX.Element | null { formRef.current?.getFieldValue('back_surface_human_grade'), ]), ); - setComputedRobogradesFrontTotal( - computeTotal([ - formRef.current?.getFieldValue('front_centering_laser_grade'), - formRef.current?.getFieldValue('front_edges_laser_grade'), - formRef.current?.getFieldValue('front_corners_laser_grade'), - formRef.current?.getFieldValue('front_surface_laser_grade'), - ]), - ); - setComputedRobogradesBackTotal( - computeTotal([ - formRef.current?.getFieldValue('back_centering_laser_grade'), - formRef.current?.getFieldValue('back_edges_laser_grade'), - formRef.current?.getFieldValue('back_corners_laser_grade'), - formRef.current?.getFieldValue('back_surface_laser_grade'), - ]), - ); setComputedRawRobogradesFrontTotal( computeTotal([ formRef.current?.getFieldValue('front_raw_centering_grade'), @@ -259,22 +241,6 @@ export function GradesForm({ task }: Props): JSX.Element | null { values?.back_surface_human_grade, ]), ); - setComputedRobogradesFrontTotal( - computeTotal([ - values?.front_centering_laser_grade, - values?.front_edges_laser_grade, - values?.front_corners_laser_grade, - values?.front_surface_laser_grade, - ]), - ); - setComputedRobogradesBackTotal( - computeTotal([ - values?.back_centering_laser_grade, - values?.back_edges_laser_grade, - values?.back_corners_laser_grade, - values?.back_surface_laser_grade, - ]), - ); setComputedRawRobogradesFrontTotal( computeTotal([ values?.front_raw_centering_grade, @@ -353,9 +319,12 @@ export function GradesForm({ task }: Props): JSX.Element | null { }, { gradeType: 'Robogrades', - totalFront: computedRobogradesFrontTotal, - totalBack: computedRobogradesBackTotal, - totalOverall: computeTotalOverall(computedRobogradesFrontTotal, computedRobogradesBackTotal), + totalFront: values?.front_overall_from_subgrades, + totalBack: values?.back_overall_from_subgrades, + totalOverall: computeTotalOverall( + values?.front_overall_from_subgrades, + values?.back_overall_from_subgrades, + ), }, { gradeType: 'Raw Robogrades', diff --git a/cvat-ui/src/reducers/grades-reducer.ts b/cvat-ui/src/reducers/grades-reducer.ts index 77218ea52d6a..e59cc5848165 100644 --- a/cvat-ui/src/reducers/grades-reducer.ts +++ b/cvat-ui/src/reducers/grades-reducer.ts @@ -29,6 +29,8 @@ const defaultState: GradesState = { back_surface_laser_grade: 0, front_overall_predicted_grade: 0, back_overall_predicted_grade: 0, + front_overall_from_subgrades: 0, + back_overall_from_subgrades: 0, front_raw_surface_minor_defect: [0, 0], front_raw_surface_major_defect: [0, 0], front_raw_edge_minor_defect: [0, 0], diff --git a/cvat-ui/src/reducers/interfaces.ts b/cvat-ui/src/reducers/interfaces.ts index f11a89f04b3a..ac39c0941715 100644 --- a/cvat-ui/src/reducers/interfaces.ts +++ b/cvat-ui/src/reducers/interfaces.ts @@ -740,6 +740,8 @@ export interface GradesState { back_surface_laser_grade: number; front_overall_predicted_grade: number; back_overall_predicted_grade: number; + front_overall_from_subgrades: number; + back_overall_from_subgrades: number; front_raw_surface_minor_defect: number[]; front_raw_surface_major_defect: number[]; front_raw_edge_minor_defect: number[];