radioviz.tools.base_tool
Base tool definition for the radioviz application.
This module defines the base classes and structures used to implement tools within the radioviz application framework. It provides the foundational abstractions for creating tools that can be integrated into the main application window, including support for analysis actions, context menu actions, and dockable views.
Classes
|
Base class for defining application tools. |
|
Event structure for tool communication. |
- class radioviz.tools.base_tool.Tool[source]
Bases:
Generic[T_Tool_Controller]Base class for defining application tools.
This class serves as the foundation for implementing various tools within the radioviz application. Each tool should inherit from this base class and implement the required methods to integrate with the application’s UI and functionality.
The tool instance is created once per application run and contains metadata about the tool along with registration information for windows and overlays. It does not contain any view-specific logic.
- _require_restore_spec() ToolWorkspace[source]
Return the workspace spec used for restoration or raise if missing.
- Returns:
The workspace specification for this restore
- Return type:
- Raises:
RuntimeError – If the restore spec has not been set
- create_analysis_action(parent: QWidget, controller: T_Tool_Controller) QAction | None[source]
Create an action for the main window ‘Analysis’ menu.
This method creates a menu action that will appear in the main window’s Analysis menu. Tools that don’t expose a trigger action should return None.
- Parameters:
parent (QWidget) – The parent widget for the action
controller (ToolController[Any, Any]) – The tool controller instance
- Returns:
A QAction instance or None if no action is needed
- Return type:
QAction or None
Create an action for the image context menu.
This method creates a menu action that will appear in the context menu when right-clicking on images. Can be None if the tool doesn’t need context menu integration.
- Parameters:
parent (QWidget) – The parent widget for the action
controller (ToolController[Any, Any]) – The tool controller instance
- Returns:
A QAction instance or None if no action is needed
- Return type:
QAction or None
- create_controller(ctx: ToolContext) T_Tool_Controller[source]
Create a controller instance for this tool.
This method must be implemented by subclasses to provide a concrete controller implementation that manages the tool’s behavior and state.
- Parameters:
ctx (ToolContext) – The tool context containing application state and services
- Returns:
A controller instance for managing the tool
- Return type:
ToolController[Any, Any]
- Raises:
NotImplementedError – Always raised by the base implementation
Create an action for the ‘View’ menu to toggle dock visibility.
This method creates a menu action that allows users to toggle the visibility of a dockable widget associated with this tool. Only applicable when the controller has a dock.
- Parameters:
parent (QWidget) – The parent widget for the action
controller (ToolController[Any, Any]) – The tool controller instance
- Returns:
A QAction instance for toggling dock visibility or None
- Return type:
QAction or None
- description: str = ''
Tooltip or description
- name: str = 'Base Tool'
Human-readable name
- overlays_to_be_registered: list[OverlaySpec] = []
List of overlay specifications to register
- tool_id: str = 'base'
Unique identifier of the tool
- windows_to_be_registered: list[WindowSpec] = []
List of window specifications to register
- class radioviz.tools.base_tool.ToolEvent(tool_id: str, event: str, payload: Any = None)[source]
Bases:
objectEvent structure for tool communication.
This dataclass represents events that can be triggered within the tool system to communicate between different components of the application.
- event: str
Type of event being triggered
- payload: Any = None
Optional payload data associated with the event
- tool_id: str
Unique identifier of the tool that triggered the event