mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
fix(image_widget): image widget adjusted
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 -960 960 960" width="48px" fill="#FFFFFF">
|
||||
<path d="M571.91-279.09h191v-194h-60v134h-131v60ZM198.09-486.91h60v-134h131v-60h-191v194Zm-53 341.04q-32.51 0-55.87-23.35-23.35-23.36-23.35-55.87v-509.82q0-32.74 23.35-56.26 23.36-23.53 55.87-23.53h669.82q32.74 0 56.26 23.53 23.53 23.52 23.53 56.26v509.82q0 32.51-23.53 55.87-23.52 23.35-56.26 23.35H145.09Zm0-79.22h669.82v-509.82H145.09v509.82Zm0 0v-509.82 509.82Z"/>
|
||||
<path d="M114.02-114.02v-308.13h68.13v192.02l547.72-547.72H537.85v-68.37h308.37v308.37h-68.37v-192.02L230.13-182.15h192.02v68.13H114.02Z"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 487 B After Width: | Height: | Size: 258 B |
11
bec_widgets/assets/toolbar_icons/fft.svg
Normal file
11
bec_widgets/assets/toolbar_icons/fft.svg
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 100 96" version="1.1" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/"
|
||||
style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<rect id="Artboard1" x="0" y="0" width="100" height="96.486" style="fill:none;"/>
|
||||
<g id="Artboard11" serif:id="Artboard1">
|
||||
<path d="M11.379,24.832C11.379,24.261 11.843,23.798 12.414,23.798C18.11,23.798 20.117,19.072 22.06,14.503C23.704,10.634 25.403,6.634 29.483,6.634C33.902,6.634 35.376,12.91 36.934,19.555C38.473,26.113 40.065,32.893 44.138,32.893C48.25,32.893 50.78,28.962 53.457,24.8C56.279,20.412 59.198,15.876 64.31,15.876C69.322,15.876 72.165,20.305 74.915,24.588C77.707,28.935 80.343,33.04 84.999,33.04C85.571,33.04 86.034,33.503 86.034,34.075C86.034,34.647 85.571,35.11 84.999,35.11C79.212,35.11 76.004,30.115 73.175,25.708C70.612,21.716 68.192,17.946 64.31,17.946C60.328,17.946 57.835,21.819 55.197,25.92C52.338,30.366 49.381,34.963 44.138,34.963C38.425,34.963 36.643,27.371 34.92,20.028C33.613,14.46 32.262,8.703 29.482,8.703C26.953,8.703 25.71,11.2 23.963,15.311C21.964,20.014 19.479,25.867 12.413,25.867C11.843,25.867 11.379,25.403 11.379,24.832M44.361,44.584C43.504,44.584 42.557,44.882 42.557,45.739L42.586,50.703L39.522,50.703L43.922,61.878L48.807,50.703L45.691,50.703L45.604,46.255C45.602,45.398 45.218,44.584 44.361,44.584ZM6.034,37.487L6.034,6.674L5,6.674L5,38.522L95,38.522L95,37.487L6.034,37.487M77.414,91.881L77.414,63.849C77.414,63.277 76.951,62.814 76.379,62.814C75.808,62.814 75.345,63.277 75.345,63.849L75.345,91.881C75.345,92.045 75.391,92.194 75.458,92.332L61.955,92.332C62.022,92.194 62.068,92.045 62.068,91.881L62.068,82.718C62.068,82.146 61.605,81.683 61.034,81.683C60.462,81.683 59.999,82.146 59.999,82.718L59.999,91.881C59.999,92.045 60.045,92.194 60.112,92.332L45.059,92.332C45.126,92.194 45.172,92.045 45.172,91.881L45.172,75.943C45.172,75.372 44.709,74.909 44.138,74.909C43.567,74.909 43.104,75.372 43.104,75.943L43.104,91.881C43.104,92.045 43.15,92.194 43.217,92.332L23.852,92.332C23.92,92.194 23.966,92.045 23.966,91.881L23.966,63.849C23.966,63.277 23.502,62.814 22.931,62.814C22.36,62.814 21.897,63.277 21.897,63.849L21.897,91.881C21.897,92.045 21.943,92.194 22.011,92.332L6.034,92.332L6.034,62.881L5,62.881L5,93.366L95,93.366L95,92.332L77.301,92.332C77.368,92.194 77.414,92.045 77.414,91.881"
|
||||
style="fill:white;fill-rule:nonzero;stroke:white;stroke-width:5px;"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.6 KiB |
3
bec_widgets/assets/toolbar_icons/lock_aspect_ratio.svg
Normal file
3
bec_widgets/assets/toolbar_icons/lock_aspect_ratio.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 -960 960 960" width="48px" fill="#FFFFFF">
|
||||
<path d="M571.91-279.09h191v-194h-60v134h-131v60ZM198.09-486.91h60v-134h131v-60h-191v194Zm-53 341.04q-32.51 0-55.87-23.35-23.35-23.36-23.35-55.87v-509.82q0-32.74 23.35-56.26 23.36-23.53 55.87-23.53h669.82q32.74 0 56.26 23.53 23.53 23.52 23.53 56.26v509.82q0 32.51-23.53 55.87-23.52 23.35-56.26 23.35H145.09Zm0-79.22h669.82v-509.82H145.09v509.82Zm0 0v-509.82 509.82Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 487 B |
BIN
bec_widgets/assets/toolbar_icons/log_scale.png
Normal file
BIN
bec_widgets/assets/toolbar_icons/log_scale.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
@ -16,6 +16,7 @@ class Widgets(str, enum.Enum):
|
||||
BECDock = "BECDock"
|
||||
BECDockArea = "BECDockArea"
|
||||
BECFigure = "BECFigure"
|
||||
BECImageWidget = "BECImageWidget"
|
||||
BECMotorMapWidget = "BECMotorMapWidget"
|
||||
BECQueue = "BECQueue"
|
||||
BECStatusBox = "BECStatusBox"
|
||||
@ -822,7 +823,7 @@ class BECImageShow(RPCBase):
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def add_monitor_image(
|
||||
def image(
|
||||
self,
|
||||
monitor: "str",
|
||||
color_map: "Optional[str]" = "magma",
|
||||
@ -833,7 +834,17 @@ class BECImageShow(RPCBase):
|
||||
**kwargs,
|
||||
) -> "BECImageItem":
|
||||
"""
|
||||
None
|
||||
Add an image to the figure. Always access the first image widget in the figure.
|
||||
|
||||
Args:
|
||||
monitor(str): The name of the monitor to display.
|
||||
color_bar(Literal["simple","full"]): The type of color bar to display.
|
||||
color_map(str): The color map to use for the image.
|
||||
data(np.ndarray): Custom data to display.
|
||||
vrange(tuple[float, float]): The range of values to display.
|
||||
|
||||
Returns:
|
||||
BECImageItem: The image item.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
@ -1125,6 +1136,180 @@ class BECImageShow(RPCBase):
|
||||
"""
|
||||
|
||||
|
||||
class BECImageWidget(RPCBase):
|
||||
@rpc_call
|
||||
def image(
|
||||
self,
|
||||
monitor: "str",
|
||||
color_map: "Optional[str]" = "magma",
|
||||
color_bar: "Optional[Literal['simple', 'full']]" = "full",
|
||||
downsample: "Optional[bool]" = True,
|
||||
opacity: "Optional[float]" = 1.0,
|
||||
vrange: "Optional[tuple[int, int]]" = None,
|
||||
**kwargs,
|
||||
) -> "BECImageItem":
|
||||
"""
|
||||
None
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set(self, **kwargs):
|
||||
"""
|
||||
Set the properties of the plot widget.
|
||||
|
||||
Args:
|
||||
**kwargs: Keyword arguments for the properties to be set.
|
||||
|
||||
Possible properties:
|
||||
- title: str
|
||||
- x_label: str
|
||||
- y_label: str
|
||||
- x_scale: Literal["linear", "log"]
|
||||
- y_scale: Literal["linear", "log"]
|
||||
- x_lim: tuple
|
||||
- y_lim: tuple
|
||||
- legend_label_size: int
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_title(self, title: "str"):
|
||||
"""
|
||||
Set the title of the plot widget.
|
||||
|
||||
Args:
|
||||
title(str): Title of the plot.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_x_label(self, x_label: "str"):
|
||||
"""
|
||||
Set the x-axis label of the plot widget.
|
||||
|
||||
Args:
|
||||
x_label(str): Label of the x-axis.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_y_label(self, y_label: "str"):
|
||||
"""
|
||||
Set the y-axis label of the plot widget.
|
||||
|
||||
Args:
|
||||
y_label(str): Label of the y-axis.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_x_scale(self, x_scale: "Literal['linear', 'log']"):
|
||||
"""
|
||||
Set the scale of the x-axis of the plot widget.
|
||||
|
||||
Args:
|
||||
x_scale(Literal["linear", "log"]): Scale of the x-axis.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_y_scale(self, y_scale: "Literal['linear', 'log']"):
|
||||
"""
|
||||
Set the scale of the y-axis of the plot widget.
|
||||
|
||||
Args:
|
||||
y_scale(Literal["linear", "log"]): Scale of the y-axis.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_x_lim(self, x_lim: "tuple"):
|
||||
"""
|
||||
Set the limits of the x-axis of the plot widget.
|
||||
|
||||
Args:
|
||||
x_lim(tuple): Limits of the x-axis.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_y_lim(self, y_lim: "tuple"):
|
||||
"""
|
||||
Set the limits of the y-axis of the plot widget.
|
||||
|
||||
Args:
|
||||
y_lim(tuple): Limits of the y-axis.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_vrange(self, vmin: "float", vmax: "float", name: "str" = None):
|
||||
"""
|
||||
Set the range of the color bar.
|
||||
If name is not specified, then set vrange for all images.
|
||||
|
||||
Args:
|
||||
vmin(float): Minimum value of the color bar.
|
||||
vmax(float): Maximum value of the color bar.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_fft(self, enable: "bool" = False, name: "str" = None):
|
||||
"""
|
||||
Set the FFT of the image.
|
||||
If name is not specified, then set FFT for all images.
|
||||
|
||||
Args:
|
||||
enable(bool): Whether to perform FFT on the monitor data.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_transpose(self, enable: "bool" = False, name: "str" = None):
|
||||
"""
|
||||
Set the transpose of the image.
|
||||
If name is not specified, then set transpose for all images.
|
||||
|
||||
Args:
|
||||
enable(bool): Whether to transpose the monitor data before displaying.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_rotation(self, deg_90: "int" = 0, name: "str" = None):
|
||||
"""
|
||||
Set the rotation of the image.
|
||||
If name is not specified, then set rotation for all images.
|
||||
|
||||
Args:
|
||||
deg_90(int): The rotation angle of the monitor data before displaying.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_log(self, enable: "bool" = False, name: "str" = None):
|
||||
"""
|
||||
Set the log of the image.
|
||||
If name is not specified, then set log for all images.
|
||||
|
||||
Args:
|
||||
enable(bool): Whether to perform log on the monitor data.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def set_grid(self, x_grid: "bool", y_grid: "bool"):
|
||||
"""
|
||||
Set the grid visibility of the plot widget.
|
||||
|
||||
Args:
|
||||
x_grid(bool): Visibility of the x-axis grid.
|
||||
y_grid(bool): Visibility of the y-axis grid.
|
||||
"""
|
||||
|
||||
@rpc_call
|
||||
def lock_aspect_ratio(self, lock: "bool"):
|
||||
"""
|
||||
Lock the aspect ratio of the plot widget.
|
||||
|
||||
Args:
|
||||
lock(bool): Lock the aspect ratio.
|
||||
"""
|
||||
|
||||
|
||||
class BECMotorMap(RPCBase):
|
||||
@property
|
||||
@rpc_call
|
||||
|
@ -1,16 +1,18 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from typing import Literal, Optional
|
||||
|
||||
import pyqtgraph as pg
|
||||
from qtpy.QtWidgets import QVBoxLayout, QWidget
|
||||
|
||||
from qtpy.QtWidgets import QWidget, QVBoxLayout
|
||||
|
||||
from bec_widgets.qt_utils.error_popups import WarningPopupUtility, SafeSlot
|
||||
from bec_widgets.qt_utils.error_popups import SafeSlot, WarningPopupUtility
|
||||
from bec_widgets.qt_utils.settings_dialog import SettingsDialog
|
||||
from bec_widgets.qt_utils.toolbar import (
|
||||
DeviceSelectionAction,
|
||||
IconAction,
|
||||
ModularToolBar,
|
||||
SeparatorAction,
|
||||
IconAction,
|
||||
DeviceSelectionAction,
|
||||
)
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.widgets.device_combobox.device_combobox import DeviceComboBox
|
||||
@ -20,11 +22,25 @@ from bec_widgets.widgets.figure.plots.image.image import ImageConfig
|
||||
from bec_widgets.widgets.figure.plots.image.image_item import BECImageItem
|
||||
|
||||
|
||||
# TODO move the actions to general place
|
||||
|
||||
|
||||
class BECImageWidget(BECWidget, QWidget):
|
||||
USER_ACCESS = []
|
||||
USER_ACCESS = [
|
||||
"image",
|
||||
"set",
|
||||
"set_title",
|
||||
"set_x_label",
|
||||
"set_y_label",
|
||||
"set_x_scale",
|
||||
"set_y_scale",
|
||||
"set_x_lim",
|
||||
"set_y_lim",
|
||||
"set_vrange",
|
||||
"set_fft",
|
||||
"set_transpose",
|
||||
"set_rotation",
|
||||
"set_log",
|
||||
"set_grid",
|
||||
"lock_aspect_ratio",
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -66,10 +82,15 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
tooltip="Autorange Image Intensity",
|
||||
checkable=True,
|
||||
),
|
||||
"aspect_ratio": IconAction(
|
||||
icon_path="lock_aspect_ratio.svg",
|
||||
tooltip="Lock image aspect ratio",
|
||||
checkable=True,
|
||||
),
|
||||
"separator_2": SeparatorAction(),
|
||||
"FFT": IconAction(icon_path="compare.svg", tooltip="Toggle FFT", checkable=True),
|
||||
"FFT": IconAction(icon_path="fft.svg", tooltip="Toggle FFT", checkable=True),
|
||||
"log": IconAction(
|
||||
icon_path="line_curve.svg", tooltip="Toggle log scale", checkable=True
|
||||
icon_path="log_scale.png", tooltip="Toggle log scale", checkable=True
|
||||
),
|
||||
"transpose": IconAction(
|
||||
icon_path="transform.svg", tooltip="Transpose Image", checkable=True
|
||||
@ -94,16 +115,16 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
|
||||
self.warning_util = WarningPopupUtility(self)
|
||||
|
||||
self.image = self.fig.image()
|
||||
self.image.apply_config(config)
|
||||
self._image = self.fig.image()
|
||||
self._image.apply_config(config)
|
||||
self.rotation = 0
|
||||
|
||||
self.config = config
|
||||
|
||||
self._hook_actions()
|
||||
|
||||
# TODO test commands
|
||||
# self.image.add_monitor_image("eiger")
|
||||
self.toolbar.widgets["drag_mode"].action.setChecked(True)
|
||||
self.toolbar.widgets["auto_range_image"].action.setChecked(True)
|
||||
|
||||
def _hook_actions(self):
|
||||
self.toolbar.widgets["connect"].action.triggered.connect(self._connect_action)
|
||||
@ -114,14 +135,15 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
self.toolbar.widgets["rectangle_mode"].action.triggered.connect(
|
||||
self.enable_mouse_rectangle_mode
|
||||
)
|
||||
self.toolbar.widgets["auto_range"].action.triggered.connect(self._auto_range_from_toolbar)
|
||||
self.toolbar.widgets["auto_range"].action.triggered.connect(self.toggle_auto_range)
|
||||
self.toolbar.widgets["auto_range_image"].action.triggered.connect(
|
||||
self.toogle_image_autorange
|
||||
self.toggle_image_autorange
|
||||
)
|
||||
self.toolbar.widgets["aspect_ratio"].action.triggered.connect(self.toggle_aspect_ratio)
|
||||
# sepatator
|
||||
self.toolbar.widgets["FFT"].action.triggered.connect(self.toogle_fft)
|
||||
self.toolbar.widgets["log"].action.triggered.connect(self.toogle_log)
|
||||
self.toolbar.widgets["transpose"].action.triggered.connect(self.toogle_transpose)
|
||||
self.toolbar.widgets["FFT"].action.triggered.connect(self.toggle_fft)
|
||||
self.toolbar.widgets["log"].action.triggered.connect(self.toggle_log)
|
||||
self.toolbar.widgets["transpose"].action.triggered.connect(self.toggle_transpose)
|
||||
self.toolbar.widgets["rotate_left"].action.triggered.connect(self.rotate_left)
|
||||
self.toolbar.widgets["rotate_right"].action.triggered.connect(self.rotate_right)
|
||||
self.toolbar.widgets["reset"].action.triggered.connect(self.reset_settings)
|
||||
@ -135,8 +157,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
def _connect_action(self):
|
||||
monitor_combo = self.toolbar.widgets["monitor"].device_combobox
|
||||
monitor_name = monitor_combo.currentText()
|
||||
# self.add_monitor_image(monitor_name)
|
||||
self.set_monitor_image(monitor_name)
|
||||
self.image(monitor_name)
|
||||
monitor_combo.setStyleSheet("QComboBox { background-color: " "; }")
|
||||
|
||||
def show_axis_settings(self):
|
||||
@ -152,7 +173,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
# User Access Methods from image
|
||||
###################################
|
||||
@SafeSlot(popup_error=True)
|
||||
def add_monitor_image(
|
||||
def image(
|
||||
self,
|
||||
monitor: str,
|
||||
color_map: Optional[str] = "magma",
|
||||
@ -163,8 +184,13 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
# post_processing: Optional[PostProcessingConfig] = None,
|
||||
**kwargs,
|
||||
) -> BECImageItem:
|
||||
return self.image.add_monitor_image(
|
||||
monitor,
|
||||
if self.toolbar.widgets["monitor"].device_combobox.currentText() != monitor:
|
||||
self.toolbar.widgets["monitor"].device_combobox.setCurrentText(monitor)
|
||||
self.toolbar.widgets["monitor"].device_combobox.setStyleSheet(
|
||||
"QComboBox {{ background-color: " "; }}"
|
||||
)
|
||||
return self._image.image(
|
||||
monitor=monitor,
|
||||
color_map=color_map,
|
||||
color_bar=color_bar,
|
||||
downsample=downsample,
|
||||
@ -173,6 +199,29 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
def set_vrange(self, vmin: float, vmax: float, name: str = None):
|
||||
"""
|
||||
Set the range of the color bar.
|
||||
If name is not specified, then set vrange for all images.
|
||||
|
||||
Args:
|
||||
vmin(float): Minimum value of the color bar.
|
||||
vmax(float): Maximum value of the color bar.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
self._image.set_vrange(vmin, vmax, name)
|
||||
|
||||
def set_color_map(self, color_map: str, name: str = None):
|
||||
"""
|
||||
Set the color map of the image.
|
||||
If name is not specified, then set color map for all images.
|
||||
|
||||
Args:
|
||||
cmap(str): The color map of the image.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
self._image.set_color_map(color_map, name)
|
||||
|
||||
def set_fft(self, enable: bool = False, name: str = None):
|
||||
"""
|
||||
Set the FFT of the image.
|
||||
@ -182,7 +231,8 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
enable(bool): Whether to perform FFT on the monitor data.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
self.image.set_fft(enable, name)
|
||||
self._image.set_fft(enable, name)
|
||||
self.toolbar.widgets["FFT"].action.setChecked(enable)
|
||||
|
||||
def set_transpose(self, enable: bool = False, name: str = None):
|
||||
"""
|
||||
@ -193,7 +243,8 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
enable(bool): Whether to transpose the monitor data before displaying.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
self.image.set_transpose(enable, name)
|
||||
self._image.set_transpose(enable, name)
|
||||
self.toolbar.widgets["transpose"].action.setChecked(enable)
|
||||
|
||||
def set_rotation(self, deg_90: int = 0, name: str = None):
|
||||
"""
|
||||
@ -204,7 +255,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
deg_90(int): The rotation angle of the monitor data before displaying.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
self.image.set_rotation(deg_90, name)
|
||||
self._image.set_rotation(deg_90, name)
|
||||
|
||||
def set_log(self, enable: bool = False, name: str = None):
|
||||
"""
|
||||
@ -215,7 +266,8 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
enable(bool): Whether to perform log on the monitor data.
|
||||
name(str): The name of the image. If None, apply to all images.
|
||||
"""
|
||||
self.image.set_log(enable, name)
|
||||
self._image.set_log(enable, name)
|
||||
self.toolbar.widgets["log"].action.setChecked(enable)
|
||||
|
||||
###################################
|
||||
# User Access Methods from Plotbase
|
||||
@ -238,7 +290,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
- y_lim: tuple
|
||||
- legend_label_size: int
|
||||
"""
|
||||
self.image.set(**kwargs)
|
||||
self._image.set(**kwargs)
|
||||
|
||||
def set_title(self, title: str):
|
||||
"""
|
||||
@ -247,7 +299,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
Args:
|
||||
title(str): Title of the plot.
|
||||
"""
|
||||
self.image.set_title(title)
|
||||
self._image.set_title(title)
|
||||
|
||||
def set_x_label(self, x_label: str):
|
||||
"""
|
||||
@ -256,7 +308,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
Args:
|
||||
x_label(str): Label of the x-axis.
|
||||
"""
|
||||
self.image.set_x_label(x_label)
|
||||
self._image.set_x_label(x_label)
|
||||
|
||||
def set_y_label(self, y_label: str):
|
||||
"""
|
||||
@ -265,7 +317,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
Args:
|
||||
y_label(str): Label of the y-axis.
|
||||
"""
|
||||
self.image.set_y_label(y_label)
|
||||
self._image.set_y_label(y_label)
|
||||
|
||||
def set_x_scale(self, x_scale: Literal["linear", "log"]):
|
||||
"""
|
||||
@ -274,7 +326,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
Args:
|
||||
x_scale(Literal["linear", "log"]): Scale of the x-axis.
|
||||
"""
|
||||
self.image.set_x_scale(x_scale)
|
||||
self._image.set_x_scale(x_scale)
|
||||
|
||||
def set_y_scale(self, y_scale: Literal["linear", "log"]):
|
||||
"""
|
||||
@ -283,7 +335,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
Args:
|
||||
y_scale(Literal["linear", "log"]): Scale of the y-axis.
|
||||
"""
|
||||
self.image.set_y_scale(y_scale)
|
||||
self._image.set_y_scale(y_scale)
|
||||
|
||||
def set_x_lim(self, x_lim: tuple):
|
||||
"""
|
||||
@ -292,7 +344,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
Args:
|
||||
x_lim(tuple): Limits of the x-axis.
|
||||
"""
|
||||
self.image.set_x_lim(x_lim)
|
||||
self._image.set_x_lim(x_lim)
|
||||
|
||||
def set_y_lim(self, y_lim: tuple):
|
||||
"""
|
||||
@ -301,23 +353,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
Args:
|
||||
y_lim(tuple): Limits of the y-axis.
|
||||
"""
|
||||
self.image.set_y_lim(y_lim)
|
||||
|
||||
def set_legend_label_size(self, legend_label_size: int):
|
||||
"""
|
||||
Set the size of the legend labels of the plot widget.
|
||||
|
||||
Args:
|
||||
legend_label_size(int): Size of the legend labels.
|
||||
"""
|
||||
self.image.set_legend_label_size(legend_label_size)
|
||||
|
||||
@SafeSlot()
|
||||
def _auto_range_from_toolbar(self):
|
||||
"""
|
||||
Set the auto range of the plot widget from the toolbar.
|
||||
"""
|
||||
self.image.set_auto_range(True, "xy")
|
||||
self._image.set_y_lim(y_lim)
|
||||
|
||||
def set_grid(self, x_grid: bool, y_grid: bool):
|
||||
"""
|
||||
@ -327,7 +363,7 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
x_grid(bool): Visibility of the x-axis grid.
|
||||
y_grid(bool): Visibility of the y-axis grid.
|
||||
"""
|
||||
self.image.set_grid(x_grid, y_grid)
|
||||
self._image.set_grid(x_grid, y_grid)
|
||||
|
||||
def lock_aspect_ratio(self, lock: bool):
|
||||
"""
|
||||
@ -336,23 +372,31 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
Args:
|
||||
lock(bool): Lock the aspect ratio.
|
||||
"""
|
||||
self.image.lock_aspect_ratio(lock)
|
||||
self._image.lock_aspect_ratio(lock)
|
||||
|
||||
###################################
|
||||
# Toolbar Actions
|
||||
###################################
|
||||
@SafeSlot()
|
||||
def toogle_fft(self):
|
||||
def toggle_auto_range(self):
|
||||
"""
|
||||
Set the auto range of the plot widget from the toolbar.
|
||||
"""
|
||||
checked = self.toolbar.widgets["auto_range"].action.isChecked()
|
||||
self._image.set_auto_range(checked, "xy")
|
||||
|
||||
@SafeSlot()
|
||||
def toggle_fft(self):
|
||||
checked = self.toolbar.widgets["FFT"].action.isChecked()
|
||||
self.set_fft(checked)
|
||||
|
||||
@SafeSlot()
|
||||
def toogle_log(self):
|
||||
def toggle_log(self):
|
||||
checked = self.toolbar.widgets["log"].action.isChecked()
|
||||
self.set_log(checked)
|
||||
|
||||
@SafeSlot()
|
||||
def toogle_transpose(self):
|
||||
def toggle_transpose(self):
|
||||
checked = self.toolbar.widgets["transpose"].action.isChecked()
|
||||
self.set_transpose(checked)
|
||||
|
||||
@ -379,30 +423,38 @@ class BECImageWidget(BECWidget, QWidget):
|
||||
self.toolbar.widgets["transpose"].action.setChecked(False)
|
||||
|
||||
@SafeSlot()
|
||||
def toogle_image_autorange(self):
|
||||
def toggle_image_autorange(self):
|
||||
"""
|
||||
Enable the auto range of the image intensity.
|
||||
"""
|
||||
checked = self.toolbar.widgets["auto_range_image"].action.isChecked()
|
||||
self.image.set_autorange(checked)
|
||||
self._image.set_autorange(checked)
|
||||
|
||||
@SafeSlot()
|
||||
def toggle_aspect_ratio(self):
|
||||
"""
|
||||
Enable the auto range of the image intensity.
|
||||
"""
|
||||
checked = self.toolbar.widgets["aspect_ratio"].action.isChecked()
|
||||
self._image.lock_aspect_ratio(checked)
|
||||
|
||||
@SafeSlot()
|
||||
def enable_mouse_rectangle_mode(self):
|
||||
self.toolbar.widgets["rectangle_mode"].action.setChecked(True)
|
||||
self.toolbar.widgets["drag_mode"].action.setChecked(False)
|
||||
self.image.plot_item.getViewBox().setMouseMode(pg.ViewBox.RectMode)
|
||||
self._image.plot_item.getViewBox().setMouseMode(pg.ViewBox.RectMode)
|
||||
|
||||
@SafeSlot()
|
||||
def enable_mouse_pan_mode(self):
|
||||
self.toolbar.widgets["drag_mode"].action.setChecked(True)
|
||||
self.toolbar.widgets["rectangle_mode"].action.setChecked(False)
|
||||
self.image.plot_item.getViewBox().setMouseMode(pg.ViewBox.PanMode)
|
||||
self._image.plot_item.getViewBox().setMouseMode(pg.ViewBox.PanMode)
|
||||
|
||||
def export(self):
|
||||
"""
|
||||
Show the export dialog for the plot widget.
|
||||
"""
|
||||
self.image.export()
|
||||
self._image.export()
|
||||
|
||||
def cleanup(self):
|
||||
self.fig.cleanup()
|
||||
|
Reference in New Issue
Block a user