"""
Dot Picker — example companion plugin.
Demonstrates the minimal pattern:
* right-click adds a point
* Ctrl+Z removes the last point
* Esc deactivates
This file is a simplified wrapper around
:class:`wolfhece._companion_factory.PointPickerCompanion`.
Import the factory class directly in your own code if you only need the
behaviour without the plugin infrastructure.
"""
from wolfhece._companion_factory import PointPickerCompanion
from wolfhece._menu_companion_abc import ActionItem
[docs]
class DotPickerCompanion(PointPickerCompanion):
"""Point-picker companion exposed as a plugin.
Adds a *"Dot Picker"* entry to the viewer's menu bar.
Inherits all interaction logic from :class:`PointPickerCompanion`.
"""
[docs]
def start(self) -> None:
"""Activate the pick action (called by the plugin manager)."""
self._start_action(
self._action_id('pick'),
'Right-click: add | Left-click: select | Ctrl+Z: undo | Esc: stop',
)
# -- menu handlers -------------------------------------------------------
[docs]
def _on_pick(self, event) -> None:
self.start()
[docs]
def _on_clear(self, event) -> None:
self.points.clear()
self.selected = -1
self._force_redraw()
self._set_status('Dot Picker: all points cleared.')