|
| 1 | +from typing import Protocol, runtime_checkable, Any |
| 2 | +from abc import abstractmethod |
| 3 | + |
| 4 | + |
| 5 | +@runtime_checkable |
| 6 | +class ImageViewerInterface(Protocol): |
| 7 | + # This are attributes, not methods. The type annotations are there |
| 8 | + # to make sure Protocol knows they are attributes. Python does not |
| 9 | + # do any checking at all of these types. |
| 10 | + click_center: bool |
| 11 | + click_drag: bool |
| 12 | + scroll_pan: bool |
| 13 | + image_width: int |
| 14 | + image_height: int |
| 15 | + zoom_level: float |
| 16 | + marker: Any |
| 17 | + cuts: Any |
| 18 | + stretch: str |
| 19 | + # viewer: Any |
| 20 | + |
| 21 | + # The methods, grouped loosely by purpose |
| 22 | + |
| 23 | + # Methods for loading data |
| 24 | + @abstractmethod |
| 25 | + def load_fits(self, file): |
| 26 | + raise NotImplementedError |
| 27 | + |
| 28 | + @abstractmethod |
| 29 | + def load_array(self, array): |
| 30 | + raise NotImplementedError |
| 31 | + |
| 32 | + @abstractmethod |
| 33 | + def load_nddata(self, data): |
| 34 | + raise NotImplementedError |
| 35 | + |
| 36 | + # Saving contents of the view and accessing the view |
| 37 | + @abstractmethod |
| 38 | + def save(self, filename): |
| 39 | + raise NotImplementedError |
| 40 | + |
| 41 | + # Marker-related methods |
| 42 | + @abstractmethod |
| 43 | + def start_marking(self): |
| 44 | + raise NotImplementedError |
| 45 | + |
| 46 | + @abstractmethod |
| 47 | + def stop_marking(self): |
| 48 | + raise NotImplementedError |
| 49 | + |
| 50 | + @abstractmethod |
| 51 | + def add_markers(self): |
| 52 | + raise NotImplementedError |
| 53 | + |
| 54 | + @abstractmethod |
| 55 | + def get_markers(self): |
| 56 | + raise NotImplementedError |
| 57 | + |
| 58 | + @abstractmethod |
| 59 | + def remove_markers(self): |
| 60 | + raise NotImplementedError |
| 61 | + |
| 62 | + # @abstractmethod |
| 63 | + # def get_all_markers(self): |
| 64 | + # raise NotImplementedError |
| 65 | + |
| 66 | + # @abstractmethod |
| 67 | + # def get_markers_by_name(self, marker_name=None): |
| 68 | + # raise NotImplementedError |
| 69 | + |
| 70 | + # Methods that modify the view |
| 71 | + @abstractmethod |
| 72 | + def center_on(self): |
| 73 | + raise NotImplementedError |
| 74 | + |
| 75 | + @abstractmethod |
| 76 | + def offset_to(self): |
| 77 | + raise NotImplementedError |
| 78 | + |
| 79 | + @abstractmethod |
| 80 | + def zoom(self): |
| 81 | + raise NotImplementedError |
0 commit comments