Skip to content

Commit 84eaffe

Browse files
committed
color fixes, fix box creation
1 parent c76ac02 commit 84eaffe

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/Annotator/reducers/general-reducer.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ export default (state: MainLayoutState, action: Action) => {
103103
const oldRegion = activeImage.regions[regionIndex]
104104
if (oldRegion.cls !== action.region.cls) {
105105
state = saveToHistory(state, "Change Region Classification")
106+
const clsIndex = state.regionClsList.indexOf(action.region.cls)
107+
if (clsIndex !== -1) {
108+
action.region.color = colors[clsIndex % colors.length]
109+
}
106110
}
107111
if (!isEqual(oldRegion.tags, action.region.tags)) {
108112
state = saveToHistory(state, "Change Region Tags")
@@ -296,7 +300,7 @@ export default (state: MainLayoutState, action: Action) => {
296300
}
297301

298302
let defaultRegionCls = undefined,
299-
defaultRegionColor = "#333333"
303+
defaultRegionColor = "#ff0000"
300304
if (activeImage && (activeImage.regions || []).length > 0) {
301305
defaultRegionCls = activeImage.regions.slice(-1)[0].cls
302306
const clsIndex = (state.regionClsList || []).indexOf(defaultRegionCls)
@@ -334,7 +338,6 @@ export default (state: MainLayoutState, action: Action) => {
334338
cls: defaultRegionCls,
335339
id: getRandomId(),
336340
}
337-
state = unselectRegions(state)
338341
state = setIn(state, ["mode"], {
339342
mode: "RESIZE_BOX",
340343
editLabelEditorAfter: true,
@@ -382,16 +385,14 @@ export default (state: MainLayoutState, action: Action) => {
382385
)
383386
}
384387
default:
385-
return state
388+
break
386389
}
387390
}
388391

389-
const regions = [...(activeImage.regions || [])]
390-
.map((r) => ({
391-
...r,
392-
editingLabels: false,
393-
highlighted: false,
394-
}))
392+
const regions = [...(getIn(state, pathToActiveImage).regions || [])]
393+
.map((r) =>
394+
setIn(r, ["editingLabels"], false).setIn(["highlighted"], false)
395+
)
395396
.concat(newRegion ? [newRegion] : [])
396397

397398
return setIn(state, [...pathToActiveImage, "regions"], regions)

src/ImageCanvas/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ export const ImageCanvas = ({
353353
context.restore()
354354
break
355355
}
356+
default:
357+
break
356358
}
357359
}
358360
context.restore()
@@ -386,7 +388,6 @@ export const ImageCanvas = ({
386388
}
387389

388390
const classPoints = useMemo(() => {
389-
// This shouldn't be called on mouse moves
390391
return regions.filter((region) => region.type === "point")
391392
}, [regions])
392393

src/RegionSelectAndTransformBoxes/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import React, { Fragment, memo } from "react"
44
import HighlightBox from "../HighlightBox"
55
import { styled } from "@material-ui/core/styles"
66
import PreventScrollToParents from "../PreventScrollToParents"
7-
import { shallowEqualObjects } from "shallow-equal"
87

98
const TransformGrabber = styled("div")({
109
width: 8,
@@ -22,7 +21,7 @@ const boxCursorMap = [
2221

2322
const arePropsEqual = (prev, next) => {
2423
return (
25-
shallowEqualObjects(prev.region, next.region) &&
24+
prev.region === next.region &&
2625
prev.dragWithPrimary === next.dragWithPrimary &&
2726
prev.createWithPrimary === next.createWithPrimary &&
2827
prev.zoomWithPrimary === next.zoomWithPrimary &&

0 commit comments

Comments
 (0)