@@ -380,6 +380,16 @@ export default (state: MainLayoutState, action: Action) => {
380
380
[ x , y ]
381
381
)
382
382
}
383
+ case "DRAW_LINE" : {
384
+ const { regionId } = state . mode
385
+ const [ region , regionIndex ] = getRegion ( regionId )
386
+ if ( ! region ) return setIn ( state , [ "mode" ] , null )
387
+ return setIn ( state , [ ...pathToActiveImage , "regions" , regionIndex ] , {
388
+ ...region ,
389
+ x2 : x ,
390
+ y2 : y ,
391
+ } )
392
+ }
383
393
case "DRAW_EXPANDING_LINE" : {
384
394
const { regionId } = state . mode
385
395
const [ expandingLine , regionIndex ] = getRegion ( regionId )
@@ -452,6 +462,16 @@ export default (state: MainLayoutState, action: Action) => {
452
462
{ ...polygon , points : polygon . points . concat ( [ [ x , y ] ] ) }
453
463
)
454
464
}
465
+ case "DRAW_LINE" : {
466
+ const [ line , regionIndex ] = getRegion ( state . mode . regionId )
467
+ if ( ! line ) break
468
+ setIn ( state , [ ...pathToActiveImage , "regions" , regionIndex ] , {
469
+ ...line ,
470
+ x2 : x ,
471
+ y2 : y ,
472
+ } )
473
+ return setIn ( state , [ "mode" ] , null )
474
+ }
455
475
case "DRAW_EXPANDING_LINE" : {
456
476
const [ expandingLine , regionIndex ] = getRegion ( state . mode . regionId )
457
477
if ( ! expandingLine ) break
@@ -591,6 +611,27 @@ export default (state: MainLayoutState, action: Action) => {
591
611
} )
592
612
break
593
613
}
614
+ case "create-line" : {
615
+ if ( state . mode && state . mode . mode === "DRAW_LINE" ) break
616
+ state = saveToHistory ( state , "Create Line" )
617
+ newRegion = {
618
+ type : "line" ,
619
+ x1 : x ,
620
+ y1 : y ,
621
+ x2 : x ,
622
+ y2 : y ,
623
+ highlighted : true ,
624
+ editingLabels : false ,
625
+ color : defaultRegionColor ,
626
+ cls : defaultRegionCls ,
627
+ id : getRandomId ( ) ,
628
+ }
629
+ state = setIn ( state , [ "mode" ] , {
630
+ mode : "DRAW_LINE" ,
631
+ regionId : newRegion . id ,
632
+ } )
633
+ break
634
+ }
594
635
case "create-keypoints" : {
595
636
state = saveToHistory ( state , "Create Keypoints" )
596
637
const [
0 commit comments