radioviz.tools.flip_image_tool
Flip image tool implementation.
This tool provides horizontal and vertical flipping of images. The flip can be applied either in-place to the current image or by creating a derived image. The implementation follows the standard tool workflow, executing the flip in a background thread and using a tool session for lifecycle management.
The module implements the following components:
FlipImageTool- Main tool entry pointFlipImageToolController- Controller handling tool logicFlipImageToolSession- Session managing the flip workflowflip_image_worker()- Background worker performing the flip
Added in version 1.1.0.
Functions
|
Flip an image in a background thread. |
Classes
|
Parameters required to compute an image flip. |
|
Output payload of the flip worker. |
Tool entry point for flipping images. |
|
|
Controller for horizontal/vertical image flips. |
|
Session handling a single flip operation. |
- class radioviz.tools.flip_image_tool.FlipImageRequest(image: ndarray, flip_mode: str)[source]
Bases:
objectParameters required to compute an image flip.
- Variables:
image (np.ndarray) – Input image data.
flip_mode (str) – Flip mode, either
'horizontal'or'vertical'.
- class radioviz.tools.flip_image_tool.FlipImageResult(image: ndarray, flip_mode: str)[source]
Bases:
objectOutput payload of the flip worker.
- Variables:
image (np.ndarray) – Flipped image data.
flip_mode (str) – Flip mode applied.
- class radioviz.tools.flip_image_tool.FlipImageTool[source]
Bases:
Tool[FlipImageToolController]Tool entry point for flipping images.
- Variables:
id (uuid.UUID) – Unique identifier for this tool instance.
tool_id (str) – String identifier used for tool registration and lookup.
name (str) – Human-readable name displayed in menus and dialogs.
description (str) – Brief description of the tool’s functionality.
_controller (Optional[FlipImageToolController]) – The controller instance created by this tool.
Initialize the flip image tool.
- create_controller(ctx: ToolContext) FlipImageToolController[source]
Create and return the tool controller.
- Parameters:
ctx (ToolContext) – The tool context providing access to application services.
- Returns:
The created tool controller.
- Return type:
- description: str = 'Flip an image horizontally or vertically.'
Tooltip or description
- name: str = 'Flip Image'
Human-readable name
- tool_id: str = 'flipimage'
Unique identifier of the tool
- class radioviz.tools.flip_image_tool.FlipImageToolController(tool_ctx: ToolContext, tool: Tool[FlipImageToolController])[source]
Bases:
ToolController[ImageWindowController,FlipImageToolSession]Controller for horizontal/vertical image flips.
This controller manages flip sessions, dependency tracking for in-place modifications, and committing flip results.
- Variables:
active_session (Optional[FlipImageToolSession]) – The currently active flip session, if any.
procedure_can_start (ActionDescriptor) – Action descriptor controlling menu enablement.
Initialize the flip tool controller.
- Parameters:
tool_ctx (ToolContext) – The tool context providing access to application services.
tool (Tool) – The tool instance that owns this controller.
- _create_new_image(image_controller: ImageWindowController, request: FlipImageRequest, result: FlipImageResult) None[source]
Create a new image window with the flipped image.
- Parameters:
image_controller (ImageWindowController) – The original image controller.
request (FlipImageRequest) – The original flip request parameters.
result (FlipImageResult) – The flip result containing the flipped image.
- _dependent_derived_images(image_controller: ImageWindowController) list[ImageWindowController][source]
Find all derived images that depend on the given image.
- Parameters:
image_controller (ImageWindowController) – The image controller to find dependents for.
- Returns:
List of derived image controllers that depend on the given image.
- Return type:
list[ImageWindowController]
- _invalidate_dependencies(image_controller: ImageWindowController) None[source]
Invalidate and close all items that depend on the given image.
- Parameters:
image_controller (ImageWindowController) – The image controller whose dependencies should be invalidated.
- _on_active_image_changed(new_window_controller: SubWindowController[Any] | None) None[source]
Handle changes to the active image controller.
- Parameters:
new_window_controller (SubWindowController) – The newly active sub-window controller.
- activate(flip_mode: str = 'horizontal', output_mode: str = 'new_image') None[source]
Activate the tool and start a flip session.
- Parameters:
flip_mode (str) – Flip mode to apply.
output_mode (str) – Output mode, either
'new_image'or'in_place'.
- commit_result(image_controller: ImageWindowController, request: FlipImageRequest, result: FlipImageResult, output_mode: str) None[source]
Commit the flip result to the image controller.
- Parameters:
image_controller (ImageWindowController) – The image controller to commit the result to.
request (FlipImageRequest) – The original flip request parameters.
result (FlipImageResult) – The flip result containing the flipped image.
output_mode (str) – The output mode, either
'new_image'or'in_place'.
- count_inplace_dependencies(image_controller: ImageWindowController) int[source]
Count the number of items that depend on the given image.
- Parameters:
image_controller (ImageWindowController) – The image controller to check dependencies for.
- Returns:
The total count of dependent items.
- Return type:
int
- create_dock(parent_window: QWidget) None[source]
Create a dock widget for this tool.
This tool does not use a dock widget, so this method returns None.
- Parameters:
parent_window – The parent window to attach the dock to.
- Returns:
None, as this tool does not use a dock.
- create_session(window_controller: ImageWindowController, flip_mode: str = 'horizontal', output_mode: str = 'new_image') FlipImageToolSession[source]
Create a new flip session for the given window controller.
- Parameters:
window_controller (SubWindowController) – The window controller to create a session for.
flip_mode (str) – Flip mode to apply.
output_mode (str) – Output mode to use.
- Returns:
A new FlipImageToolSession instance.
- Return type:
- inplace_dependency_summary(image_controller: ImageWindowController) str[source]
Generate a summary of items that depend on the given image.
- Parameters:
image_controller (ImageWindowController) – The image controller to get dependencies for.
- Returns:
A formatted string summarizing the dependent items.
- Return type:
str
Get the menu specifications for this tool.
- Returns:
List of menu specifications defining the tool’s menu entries.
- Return type:
List[ToolMenuSpec]
- class radioviz.tools.flip_image_tool.FlipImageToolSession(tool_controller: FlipImageToolController, window_controller: ImageWindowController, flip_mode: str, output_mode: str)[source]
Bases:
BaseToolSession[FlipImageToolController,ImageWindowController]Session handling a single flip operation.
- Variables:
dialog_window (Optional[object]) – Optional dialog window (unused for this tool).
Initialize a new flip tool session.
- Parameters:
tool_controller (FlipImageToolController) – The tool controller that owns this session.
window_controller (SubWindowController) – The image window controller to operate on.
flip_mode (str) – Flip mode to apply.
output_mode (str) – Output mode, either
'new_image'or'in_place'.
- Raises:
TypeError – If window_controller is not an ImageWindowController.
- _on_error(error: Exception) None[source]
Handle errors from the flip worker.
- Parameters:
error (Exception) – The exception that was raised by the worker.
- _on_result_ready(result: FlipImageResult) None[source]
Handle successful completion of the flip worker.
- Parameters:
result (FlipImageResult) – The flip result containing the flipped image.
- radioviz.tools.flip_image_tool.flip_image_worker(request: FlipImageRequest) FlipImageResult[source]
Flip an image in a background thread.
- Parameters:
request (FlipImageRequest) – Parameters required to compute an image flip.
- Returns:
Result containing the flipped image and flip mode.
- Return type:
- Raises:
ValueError – If an unknown flip mode is requested.