"""
This module contains classes for managing various aspects of image processing and manipulation in the application's user interface.
Classes:
- PanoramaConfig: Manages panorama view configuration settings and UI interactions.
- RecenterConfig: Handles recentering of images and related UI controls.
- ControlViewRotate: Manages image rotation functionality and UI controls.
"""
[docs]
class ControlViewRotate:
"""
This class manages the rotation of images in the application's user interface.
Methods:
- __init__(controller): Initializes the ControlViewRotate instance.
- _connect_event(): Connects GUI events to their corresponding methods.
- _change_rotate_degree(direction): Rotates the result image in the specified direction.
- _show_rotation_value(): Sets the value of the rotation angle in the GUI.
- _rotation_change_value(): Updates the rotation angle when the user changes its value.
- _rotation_image_ori_change_value(): Updates the rotation angle for the original image.
- _rotation_original_change_value(): Updates the rotation angle for the original image.
- set_initial_value_to_ui_rotate(): Sets the initial rotation values in the user interface.
"""
def __init__(self, controller):
self._controller = controller
self._ui_object = self._controller.ui_object
self._model = controller.model
self._connect_event()
def _connect_event(self):
self._ui_object.rotate_left_button.clicked.connect(lambda: self._change_rotate_degree("left"))
self._ui_object.rotate_right_button.clicked.connect(lambda: self._change_rotate_degree("right"))
self._ui_object.doubleSpinBox_rotate.valueChanged.connect(self._rotation_change_value)
self._ui_object.doubleSpinBox_rotate_ori.valueChanged.connect(self._rotation_image_ori_change_value)
def _change_rotate_degree(self, direction):
"""
Rotate the result image in the specified direction.
Arg:
direction (str): The direction to rotate the image. Must be either "left" or "right".
"""
if self._model.debug_mode:
self._model.activity_logger.info("ControlViewRotate: _change_rotate_degree(), "
f"Get notation change rotate image to the {direction}")
if self._model.image_original is not None:
if direction == "left":
self._model.view_properties.rotate_left()
else:
self._model.view_properties.rotate_right()
self._show_rotation_value()
self._controller.display_image_to_ui()
else:
self._ui_object.doubleSpinBox_rotate.setEnabled(False)
def _show_rotation_value(self):
"""
Set the value of the rotation angle in the GUI.
Disable the signals of the GUI double spin box widget, sets its value to
the current rotation angle and enables the signals back again.
Return:
None
"""
if self._model.debug_mode:
self._model.activity_logger.info("ControlViewRotate: _show_rotation_value(), "
"Show rotation value to user interface")
self._ui_object.doubleSpinBox_rotate.setEnabled(True)
self._ui_object.doubleSpinBox_rotate.blockSignals(True)
self._ui_object.doubleSpinBox_rotate.setValue(self._model.view_properties.rotate_degree)
self._ui_object.doubleSpinBox_rotate.blockSignals(False)
def _rotation_change_value(self):
"""
Update the rotation angle when the user changes its value.
Set the new value of the rotation angle to the private attribute and also
to the model of the application. If the rubber band tool is active, it
updates the result image and the percentage of zoom. Otherwise, it creates
a new result image.
"""
if self._model.debug_mode:
self._model.activity_logger.info("ControlViewRotate: _rotation_change_value(), "
"Change rotation value from double spin box user interface")
if self._model.image_original is not None:
value = self._ui_object.doubleSpinBox_rotate.value()
self._model.view_properties.change_rotate_value(value)
self._controller.display_image_to_ui()
def _rotation_image_ori_change_value(self):
"""
Update the rotation angle when the user changes its value.
Set the new value of the rotation angle to the private attribute and also
to the model of the application. If the rubber band tool is active, it
updates the result image and the percentage of zoom. Otherwise, it creates
a new result image.
"""
if self._model.image_original is not None:
value = self._ui_object.doubleSpinBox_rotate_ori.value()
self._model.main_config['Image_original']['rotate'] = round(value, 2)
self._model.save_main_config_update()
if self._ui_object.checkBox_reverse_view.isChecked():
self._controller.view_recenter.create_image_recenter()
self._controller.display_image_to_ui()
def _rotation_original_change_value(self):
"""
Update the rotation angle when the user changes its value.
Set the new value of the rotation angle to the private attribute and also
to the model of the application. If the rubber band tool is active, it
updates the result image and the percentage of zoom. Otherwise, it creates
a new result image.
"""
if self._model.debug_mode:
self._model.activity_logger.info("ControlViewRotate: _rotation_original_change_value(), "
"Change rotation value image original from double spin box user interface")
if self._model.image_original is not None:
value = self._ui_object.doubleSpinBox_rotate_ori.value()
self._model.view_properties.change_rotation_original_value(value)
[docs]
def set_initial_value_to_ui_rotate(self):
"""
Set the initial rotation values to the user interface.
This method sets the initial rotation values for the processed image and the original image
to the corresponding spin boxes in the user interface.
Return:
None
"""
self._ui_object.doubleSpinBox_rotate.blockSignals(True)
self._ui_object.doubleSpinBox_rotate_ori.blockSignals(True)
rotate_result = self._model.main_config["Rotate_result"]
rotate_original = self._model.main_config["Image_original"]["rotate"]
self._ui_object.doubleSpinBox_rotate.setValue(rotate_result)
self._ui_object.doubleSpinBox_rotate_ori.setValue(rotate_original)
self._ui_object.doubleSpinBox_rotate.blockSignals(False)
self._ui_object.doubleSpinBox_rotate_ori.blockSignals(False)