Skip to content

add polygon button to gridplot toolbar #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2023
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy