5757
5858
5959def create_window (tool_classes : tuple [type [RectangularActionTool ], ...]) -> PlotWindow :
60+ """Create a window with the given tools. The plot contains a curve, an image and a
61+ legend.
62+
63+ Args:
64+ tool_classes: tools to add to the window.
65+
66+ Returns:
67+ PlotWindow: The window containing the tools.
68+ """
6069 items = make_curve_image_legend ()
6170 win = ptv .show_items (
6271 items , wintitle = "Unit tests for RectangularActionTools" , auto_tools = True
@@ -66,18 +75,13 @@ def create_window(tool_classes: tuple[type[RectangularActionTool], ...]) -> Plot
6675 _ = win .manager .add_tool (toolklass )
6776
6877 assert len (tool_classes ) > 0
69- # win.manager.set_default_tool(tool)
7078
7179 return win
7280
7381
74- def use_tool (win : PlotWindow , tool_class : type [RectangularActionTool ]):
75- filter_ = win .manager .get_plot ().filter
76- if (tool := win .manager .get_tool (tool_class )) is not None :
77- tool .end_rect (filter_ , P0 , P1 )
78-
79-
8082def _test_annotation_tools (tool_classes : tuple [type [RectangularActionTool ], ...]):
83+ """Generic test for annotation tool. Simulates a mouse drag on the plot and checks
84+ that the tool is activated and deactivated correctly."""
8185 with qt_app_context (exec_loop = False ) as qapp :
8286 win = create_window (tool_classes )
8387 default_tool = win .manager .get_default_tool ()
@@ -94,66 +98,82 @@ def _test_annotation_tools(tool_classes: tuple[type[RectangularActionTool], ...]
9498
9599
96100def test_annotated_circle_tool ():
101+ """Test the annotated circle tool."""
97102 _test_annotation_tools ((AnnotatedCircleTool ,))
98103
99104
100105def test_annotated_ellipse_tool ():
106+ """Test the annotated ellipse tool."""
101107 _test_annotation_tools ((AnnotatedEllipseTool ,))
102108
103109
104110def test_annotated_oblique_rectangle_tool ():
111+ """Test the annotated oblique rectangle tool."""
105112 _test_annotation_tools ((AnnotatedObliqueRectangleTool ,))
106113
107114
108115def test_annotated_point_tool ():
116+ """Test the annotated point tool."""
109117 _test_annotation_tools ((AnnotatedPointTool ,))
110118
111119
112120def test_annotated_rectangle_tool ():
121+ """Test the annotated rectangle tool."""
113122 _test_annotation_tools ((AnnotatedRectangleTool ,))
114123
115124
116125def test_annotated_segment_tool ():
126+ """Test the annotated segment tool."""
117127 _test_annotation_tools ((AnnotatedSegmentTool ,))
118128
119129
120130def test_avg_cross_section_tool ():
131+ """Test the average cross section tool."""
121132 _test_annotation_tools ((AverageCrossSectionTool ,))
122133
123134
124135def test_cross_section_tool ():
136+ """Test the cross section tool."""
125137 _test_annotation_tools ((CrossSectionTool ,))
126138
127139
128140def test_snapshot_tool ():
141+ """Test the snapshot tool."""
129142 _test_annotation_tools ((SnapshotTool ,))
130143
131144
132145def test_image_stats_tool ():
146+ """Test the image stats tool."""
133147 _test_annotation_tools ((ImageStatsTool ,))
134148
135149
136150def test_circle_tool ():
151+ """Test the circle tool."""
137152 _test_annotation_tools ((CircleTool ,))
138153
139154
140155def test_ellipse_tool ():
156+ """Test the ellipse tool."""
141157 _test_annotation_tools ((EllipseTool ,))
142158
143159
144160def test_oblique_rectangle_tool ():
161+ """Test the oblique rectangle tool."""
145162 _test_annotation_tools ((ObliqueRectangleTool ,))
146163
147164
148165def test_point_tool ():
166+ """Test the point tool."""
149167 _test_annotation_tools ((PointTool ,))
150168
151169
152170def test_rectangle_tool ():
171+ """Test the rectangle tool."""
153172 _test_annotation_tools ((RectangleTool ,))
154173
155174
156175def test_segment_tool ():
176+ """Test the segment tool."""
157177 _test_annotation_tools ((SegmentTool ,))
158178
159179
0 commit comments