Skip to content

Commit 6932de7

Browse files
committed
Renamed FreeFormTool to PolygonTool
1 parent c85ed29 commit 6932de7

11 files changed

Lines changed: 92 additions & 41 deletions

File tree

doc/features/tools/reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Shape tools
5858

5959
.. autoclass:: plotpy.tools.MultiLineTool
6060
:members:
61-
.. autoclass:: plotpy.tools.FreeFormTool
61+
.. autoclass:: plotpy.tools.PolygonTool
6262
:members:
6363
.. autoclass:: plotpy.tools.LabelTool
6464
:members:

plotpy/items/shape/polygon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(
7171
self.points = np.zeros((0, 2), float)
7272
if points is not None:
7373
self.set_points(points)
74-
self.setIcon(get_icon("freeform.png"))
74+
self.setIcon(get_icon("polygon.png"))
7575

7676
def types(self) -> tuple[type[IItemType], ...]:
7777
"""Returns a group or category for this item.

plotpy/tests/features/test_autoscale_shapes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
AnnotatedSegmentTool,
2222
CircleTool,
2323
EllipseTool,
24-
FreeFormTool,
2524
LabelTool,
2625
MultiLineTool,
2726
ObliqueRectangleTool,
2827
PlaceAxesTool,
28+
PolygonTool,
2929
RectangleTool,
3030
SegmentTool,
3131
)
@@ -41,7 +41,7 @@ def create_window():
4141
CircleTool,
4242
EllipseTool,
4343
MultiLineTool,
44-
FreeFormTool,
44+
PolygonTool,
4545
PlaceAxesTool,
4646
AnnotatedRectangleTool,
4747
AnnotatedObliqueRectangleTool,

plotpy/tests/features/test_imagesuperp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from plotpy.builder import make
1414
from plotpy.tests import get_path
15-
from plotpy.tools import EllipseTool, FreeFormTool, PlaceAxesTool, RectangleTool
15+
from plotpy.tools import EllipseTool, PlaceAxesTool, PolygonTool, RectangleTool
1616

1717

1818
def create_window():
@@ -26,7 +26,7 @@ def create_window():
2626
type="image",
2727
size=(800, 600),
2828
)
29-
for toolklass in (RectangleTool, EllipseTool, FreeFormTool, PlaceAxesTool):
29+
for toolklass in (RectangleTool, EllipseTool, PolygonTool, PlaceAxesTool):
3030
win.manager.add_tool(toolklass)
3131
return win
3232

plotpy/tests/tools/test_customize_shape_tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from plotpy.tests import get_path
1616
from plotpy.tools import (
1717
EllipseTool,
18-
FreeFormTool,
1918
MultiLineTool,
19+
PolygonTool,
2020
RectangleTool,
2121
SegmentTool,
2222
)
@@ -50,7 +50,7 @@ def create_window():
5050
EllipseTool,
5151
SegmentTool,
5252
MultiLineTool,
53-
FreeFormTool,
53+
PolygonTool,
5454
):
5555
win.manager.add_tool(toolklass, handle_final_shape_cb=customize_shape)
5656
return win

plotpy/tests/tools/test_image_plot_tools.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# guitest: show
99

1010
from guidata.qthelpers import qt_app_context
11+
from qtpy import QtWidgets as QW
1112

1213
from plotpy.builder import make
1314
from plotpy.items import Marker
@@ -21,19 +22,21 @@
2122
AnnotatedSegmentTool,
2223
CircleTool,
2324
EllipseTool,
24-
FreeFormTool,
2525
HCursorTool,
2626
HRangeTool,
2727
LabelTool,
2828
MultiLineTool,
2929
ObliqueRectangleTool,
3030
PlaceAxesTool,
31+
PolygonTool,
3132
RectangleTool,
3233
SegmentTool,
3334
VCursorTool,
3435
XCursorTool,
3536
)
3637

38+
TOOLBAR_ID = "toolbar2"
39+
3740

3841
def create_window():
3942
win = make.dialog(
@@ -43,6 +46,10 @@ def create_window():
4346
type="image",
4447
size=(800, 600),
4548
)
49+
toolbar2 = QW.QToolBar()
50+
win.layout().addWidget(toolbar2)
51+
win.manager.add_toolbar(toolbar2, TOOLBAR_ID)
52+
4653
for toolklass in (
4754
LabelTool,
4855
HRangeTool,
@@ -55,7 +62,7 @@ def create_window():
5562
CircleTool,
5663
EllipseTool,
5764
MultiLineTool,
58-
FreeFormTool,
65+
PolygonTool,
5966
PlaceAxesTool,
6067
AnnotatedRectangleTool,
6168
AnnotatedObliqueRectangleTool,
@@ -64,7 +71,7 @@ def create_window():
6471
AnnotatedSegmentTool,
6572
AnnotatedPointTool,
6673
):
67-
win.manager.add_tool(toolklass)
74+
win.manager.add_tool(toolklass, toolbar_id=TOOLBAR_ID)
6875
return win
6976

7077

plotpy/tests/unit/test_multiline_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
keyboard_event,
1212
mouse_event_at_relative_plot_pos,
1313
)
14-
from plotpy.tools import FreeFormTool, MultiLineTool
14+
from plotpy.tools import MultiLineTool, PolygonTool
1515

1616

1717
def test_free_form_tool():
1818
"""Test the free form tool."""
1919
corners = np.array(((0.1, 0.1), (0.1, 0.8), (0.8, 0.8), (0.8, 0.1)))
2020
with qt_app_context(exec_loop=False):
21-
win, tool = create_window(FreeFormTool)
21+
win, tool = create_window(PolygonTool)
2222

2323
# drag_mouse(win, x_path, y_path)
2424
for x, y in corners:

plotpy/tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
from .shape import (
8989
CircleTool,
9090
EllipseTool,
91-
FreeFormTool,
91+
PolygonTool,
9292
MultiLineTool,
9393
ObliqueRectangleTool,
9494
PointTool,

plotpy/tools/plot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from __future__ import annotations
99

10+
from typing import TYPE_CHECKING
11+
1012
from guidata.configtools import get_icon
1113
from guidata.qthelpers import add_actions, add_separator
1214
from qtpy import QtCore as QC
@@ -17,7 +19,6 @@
1719
from plotpy.events import ZoomRectHandler, setup_standard_tool_filter
1820
from plotpy.interfaces import IImageItemType, IShapeItemType
1921
from plotpy.items import RectangleShape, get_items_in_rectangle
20-
from plotpy.plot import BasePlot, PlotManager
2122
from plotpy.tools.base import (
2223
CommandTool,
2324
DefaultToolbarID,
@@ -26,6 +27,9 @@
2627
RectangularActionTool,
2728
)
2829

30+
if TYPE_CHECKING:
31+
from plotpy.plot import BasePlot, PlotManager
32+
2933

3034
class DoAutoscaleTool(CommandTool):
3135
"""A tool to perform autoscale for associated plot."""

0 commit comments

Comments
 (0)