RodTracker.ui.mainwindow

TBD

class RodTrackWindow(*args, **kwargs)[source]

Bases: QMainWindow

The main window for the Rod Tracker application.

This class handles most of the interaction between the user and the GUI elements of the Rod Tracker application. It also sets up the backend objects necessary for this application.

Parameters
  • *args (iterable) – Positional arguments for the QMainWindow superclass.

  • **kwargs (dict) – Keyword arguments for the QMainWindow superclass.

ui

The GUI main window object, that contains all other visual objects.

Type

Ui_MainWindow

cameras

A copy of all image display objects (views) from the GUI main window.

Type

List[RodImageWidget]

image_managers

Manager objects for loaded/selected image datasets. There is one associated with each RodImageWidget in cameras.

Type

List[ImageData]

attempt_saving() None[source]

Handles the propagation of a saving attempt by a user.

change_color(to_color: str)[source]

Activates the given color QRadioButton in the GUI.

Parameters

to_color (str) – The color that is activated.

Returns

None

change_view(direction: int) None[source]

Helper method for programmatic changes of the camera tabs.

closeEvent(a0: QCloseEvent) None[source]

Reimplements QMainWindow.closeEvent(a0).

In case of unsaved changes, the user is asked to save or discard these before closing the application. The closing can be aborted with this dialog.

Parameters

a0 (QCloseEvent) –

Returns

None

color_change(state: bool) None[source]

Handles changes of the QRadioButtons for color selection.

connect_signals()[source]

Connect all signals and slots of the Rod Tracker objects.

display_rod_changed(number: str)[source]

Handles a change of rod numbers in the user’s input field.

eventFilter(source: QObject, event: QEvent) bool[source]

Intercepts events, here modified scroll events for zooming.

Parameters
  • source (QObject) –

  • event (QEvent) –

Returns

boolTrue, if the event shall not be propagated further. False, if the event shall be passed to the next object to be handled.

fit_to_window()[source]

Fits the image to the space available in the GUI.

Fits the image to the space available for the image in the GUI and keeps the aspect ratio as in the original.

Returns

None

get_selected_color()[source]

Gets the currently selected color in the GUI.

Returns

str – The color that is currently selected in the GUI.

images_loaded(frames: int, cam_id: str, folder: Path)[source]

Handles updates of loaded image datasets.

Updates GUI elements to match the newly loaded image dataset.

Parameters
  • frames (int) – Number of loaded frames.

  • cam_id (str) – ID of the loaded dataset/folder/camera.

  • folder (Path) – Folder from which the images were loaded.

logger: ActionLogger

A logger object keeping track of users’ actions performed on the main window, i.e. data and image loading and saving.

Type

ActionLogger

logger_id: str = 'main'

The ID provided to the logger for accountability of the actions in the GUI.

Default is "main".

Type

str

method_2D_changed(_: bool) None[source]

Handles changes of 2D display method selection.

method_3D_changed(_: bool) None[source]

Handles changes of 3D display method selection.

next_image(frame: int, frame_idx: int)[source]

Handles updates of the currently displayed image.

Updates the GUI controls to match the currently displayed image.

Parameters
  • frame (int) – Frame number of the newly displayed image.

  • frame_idx (int) – Index of the newly displayed image in the whole image dataset.

original_size()[source]

Displays the currently loaded image in its native size.

request_redo

Is emitted when the user wants to redo a previously reverted action.

The payload is the ID of the widget on which the last action shall be redone.

Type

pyqtSignal(str)

request_undo

Is emitted when the user wants to revert an action.

The payload is the ID of the widget on which the last action shall be reverted.

Type

pyqtSignal(str)

requesting_redo() None[source]

Helper method to emit a request for repeating the last action.

Hint

Emits

requesting_undo() None[source]

Helper method to emit a request for reverting the last action.

Hint

Emits

resizeEvent(a0: QResizeEvent) None[source]

Reimplements QMainWindow.resizeEvent(a0).

Currently not used.

Parameters

a0 (QResizeEvent.) –

Returns

None

rods_loaded(input: Path, output: Path, new_colors: List[str])[source]

Handles updates of loaded rod position datasets.

Updates GUI elements to match the newly loaded rod position dataset.

Parameters
  • input (Path) – Path to the folder the position data is loaded from.

  • output (Path) – Path to the (automatically) selected folder for later output of the corrected dataset.

  • new_colors (List[str]) – Colors for which data is available in the loaded dataset.

scale_image(factor: float)[source]

Sets a new relative scaling for the current image.

Sets a new scaling to the currently displayed image. The scaling factor acts relative to the already applied scaling.

Parameters

factor (float) –

The relative scaling factor. Example:

factor=1.1, current scaling: 2.0 ==> new scaling: 2.2

Returns

None

show_2D_changed(state: int)[source]

Catches a QCheckBox state change to display or clear rods in 2D.

Parameters

state (int) – The new state of the QCheckbox {0, 2}

Returns

None

show_3D_changed(state: int)[source]

Catches a QCheckBox state change to display or clear rods in 3D.

Parameters

state (int) – The new state of the QCheckbox {0, 2}

Returns

None

show_next(direction: int)[source]

Attempt to open the next image.

Attempt to open the next image in the direction provided relative to the currently opened image.

Parameters

direction (int) – Direction of the image to open next. Its the index relative to the currently opened image. a) direction = 3 -> opens the image three positions further b) direction = -1 -> opens the previous image c) direction = 0 -> keeps the current image open

Returns

None

slider_moved(pos: int)[source]

Handle image displays corresponding to slider movements.

Parameters

pos (int) – New position of the slider, that is thereby the new image index to be displayed.

tab_busy_changed(tab_idx: int, is_busy: bool)[source]
tab_has_changes(has_changes: bool, cam_id: str) None[source]

Changes the tabs text to indicate it has (no) changes.

Parameters
  • has_changes (bool) –

  • cam_id (str) – Camera which indicated it now has (no) changes.

tree_selection(item: QTreeWidgetItem, col: int)[source]

Handle the selection of a rod & frame in the RodTree widget.

Parameters
  • item (QTreeWidgetItem) – Selected item in the RodTree widget.

  • col (int) – Column of the RodTree widget the item was selected in.

update_settings(settings: dict)[source]

Catches updates of the settings from a Settings class.

Checks for the keys relevant to itself and updates the corresponding attributes. Updates itself with the new settings in place.

Parameters

settings (dict) –

Returns

None

view_changed(new_idx: int)[source]

Handles switches between the camera tabs.

Handles the switches between the camera tabs and depending on the GUI state tries to load the same frame for the newly displayed tab as in the old one.

Parameters

new_idx (int) – The index of the tab that is shown next.

Returns

None

static warning_unsaved() bool[source]

Warns that there are unsaved changes that might get lost.

Issues a warning popup to the user to either discard any unsaved changes or stay in the current state to prevent changes get lost.

Returns

boolTrue, if changes shall be discarded. False, if the user aborted.

blank_icon() QIcon[source]
busy_icon() QIcon[source]
reconnect(signal: pyqtSignal, newhandler: Optional[Callable] = None, oldhandler: Optional[Callable] = None) None[source]

(Re-)connect handler(s) to a signal.

Connect a new handler function to a signal while either removing all other, previous handlers, or just one specific one.

Parameters
  • signal (QtCore.pyqtSignal) –

  • newhandler (Callable, optional) – By default None.

  • oldhandler (Callable, optional) – Handler function currently connected to signal. All connected functions will be removed, if this parameters is None. By default None.