Skip to content

Commit

Permalink
refactor: make display and display value independent
Browse files Browse the repository at this point in the history
  • Loading branch information
wadjih-bencheikh18 committed Aug 23, 2023
1 parent dada7ee commit eae54c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/roi/annotation/ConvexHullAnnotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ function ConvexHullAnnotation({ roi }: ConvexHullAnnotationProps) {
[fontColor, fontSize],
);

if (!enabled) return null;
if (!enabled && !displayValue) return null;

return (
<g>
<polygon points={svgPoints} style={polygonStyle} />
{enabled && <polygon points={svgPoints} style={polygonStyle} />}
{displayValue && (
<text x={roi.width / 2} y={roi.height + 1} style={textStyle}>
{roi.convexHull.surface}
Expand Down
6 changes: 4 additions & 2 deletions src/components/roi/annotation/FeretAnnotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function FeretAnnotation({ roi }: FeretAnnotationProps) {
[fontColor, fontSize],
);

if (!enabled) return null;
if (!enabled && !displayValue) return null;

return (
<>
Expand All @@ -66,7 +66,9 @@ function FeretAnnotation({ roi }: FeretAnnotationProps) {
// eslint-disable-next-line react/no-array-index-key
key={`${roi.id}-${index}`}
>
<line x1={x1} y1={y1} x2={x2} y2={y2} style={lineStyle} />
{enabled && (
<line x1={x1} y1={y1} x2={x2} y2={y2} style={lineStyle} />
)}
{displayValue && (
<text
x={0}
Expand Down
7 changes: 3 additions & 4 deletions src/components/roi/annotation/MBRAnnotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ function MBRAnnotation({ roi }: MBRAnnotationProps) {
}),
[fontColor, fontSize],
);
if (!enabled) {
return null;
}

if (!enabled && !displayValue) return null;

return (
<g>
<polygon points={svgPoints} style={polygonStyle} />
{enabled && <polygon points={svgPoints} style={polygonStyle} />}
{displayValue && (
<text x={roi.width / 2} y={-1} style={textStyle}>
{roi.width} x {roi.height} ({roi.surface} pixels)
Expand Down

0 comments on commit eae54c1

Please sign in to comment.