20
20
from ._defaults import create_controller
21
21
from ._subplot import Subplot
22
22
from ._record_mixin import RecordMixin
23
-
23
+ from .. graphics . selectors import PolygonSelector
24
24
25
25
def to_array (a ) -> np .ndarray :
26
26
if isinstance (a , np .ndarray ):
@@ -481,6 +481,14 @@ def __init__(self, plot: GridPlot):
481
481
tooltip = "y-axis direction" ,
482
482
)
483
483
484
+ self .add_polygon_button = Button (
485
+ value = False ,
486
+ disabled = False ,
487
+ icon = "draw-polygon" ,
488
+ layout = Layout (width = "auto" ),
489
+ tooltip = "add PolygonSelector"
490
+ )
491
+
484
492
self .record_button = ToggleButton (
485
493
value = False ,
486
494
disabled = False ,
@@ -510,6 +518,7 @@ def __init__(self, plot: GridPlot):
510
518
self .panzoom_controller_button ,
511
519
self .maintain_aspect_button ,
512
520
self .flip_camera_button ,
521
+ self .add_polygon_button ,
513
522
self .record_button ,
514
523
self .dropdown ,
515
524
]
@@ -580,3 +589,8 @@ def record_plot(self, obj):
580
589
self .record_button .value = False
581
590
else :
582
591
self .plot .record_stop ()
592
+
593
+ def add_polygon (self , obj ):
594
+ ps = PolygonSelector (edge_width = 3 , edge_color = "magenta" )
595
+
596
+ self .current_subplot .add_graphic (ps , center = False )
0 commit comments