Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion fastplotlib/layouts/_gridplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ._defaults import create_controller
from ._subplot import Subplot
from ._record_mixin import RecordMixin

from ..graphics.selectors import PolygonSelector

def to_array(a) -> np.ndarray:
if isinstance(a, np.ndarray):
Expand Down Expand Up @@ -481,6 +481,14 @@ def __init__(self, plot: GridPlot):
tooltip="y-axis direction",
)

self.add_polygon_button = Button(
value=False,
disabled=False,
icon="draw-polygon",
layout=Layout(width="auto"),
tooltip="add PolygonSelector"
)

self.record_button = ToggleButton(
value=False,
disabled=False,
Expand Down Expand Up @@ -510,6 +518,7 @@ def __init__(self, plot: GridPlot):
self.panzoom_controller_button,
self.maintain_aspect_button,
self.flip_camera_button,
self.add_polygon_button,
self.record_button,
self.dropdown,
]
Expand Down Expand Up @@ -580,3 +589,8 @@ def record_plot(self, obj):
self.record_button.value = False
else:
self.plot.record_stop()

def add_polygon(self, obj):
ps = PolygonSelector(edge_width=3, edge_color="magenta")

self.current_subplot.add_graphic(ps, center=False)