diff --git a/nion/swift/ExportDialog.py b/nion/swift/ExportDialog.py index 4e1ac606..b4f53c71 100644 --- a/nion/swift/ExportDialog.py +++ b/nion/swift/ExportDialog.py @@ -23,6 +23,7 @@ from nion.swift.model import Utility from nion.swift import DocumentController from nion.swift import DisplayPanel +from nion.swift import Inspector from nion.ui import Declarative from nion.ui import Dialog from nion.ui import UserInterface @@ -263,6 +264,7 @@ class UnitType(enum.Enum): class ExportSizeModel(Observable.Observable): def __init__(self, display_item: DisplayItem.DisplayItem) -> None: super().__init__() + self.__display_item = display_item display_size = self.__calculate_display_size_in_pixels(display_item) self.__last_input_value: float = display_size.width self.__aspect_ratio = display_size.width / display_size.height @@ -273,10 +275,28 @@ def __init__(self, display_item: DisplayItem.DisplayItem) -> None: self.__enforce_width_height_constraints() def __calculate_display_size_in_pixels(self, display_item: DisplayItem.DisplayItem) -> Geometry.IntSize: - if display_item.display_data_shape and len(display_item.display_data_shape) == 2: - return Geometry.IntSize(height=display_item.display_data_shape[0], width=display_item.display_data_shape[1]) + if display_item.display_data_shape and self.__display_item.used_display_type != "line_plot": + return Geometry.IntSize(height=display_item.display_data_shape[-2], width=display_item.display_data_shape[-1]) return Geometry.IntSize(height=288, width=480) + @property + def title(self) -> typing.Optional[str]: + title_str = self.__display_item.displayed_title + return title_str + + @property + def shape(self) -> typing.Optional[str]: + shape_str = "(" + self.__display_item.data_info.data_shape_str + ")" + return shape_str + + @property + def calibration(self) -> typing.Optional[str]: + if self.__display_item.data_info.calibrated_dimensional_calibrations_str: + calibration_str = "(" + self.__display_item.data_info.calibrated_dimensional_calibrations_str + ")" + return calibration_str + else: + return "" + def __enforce_width_height_constraints(self) -> None: min_size_in_inches = 3.0 max_size_in_inches = 12.0 @@ -384,36 +404,61 @@ class ExportSVGHandler(Declarative.Handler): def __init__(self, model: ExportSizeModel) -> None: super().__init__() - self.model = model + self.model = model # Ensure model is an attribute of the handler u = Declarative.DeclarativeUI() self._float_to_string_converter = Converter.FloatToStringConverter() self.ui_view = u.create_column( u.create_row( - u.create_label(text=_("Width:"), width=80), + u.create_label(text="Title", width=130), + u.create_label(text="@binding(model.title)"), + u.create_stretch(), + spacing=8 + ), + u.create_row( + u.create_label(text="Data shape (Pixels) ", width=130), + u.create_label(text="@binding(model.shape)"), + u.create_stretch(), + spacing=8 + ), + u.create_row( + u.create_label(text="Shape (calibrated units) ", width=130), + u.create_label(text="@binding(model.calibration)"), + u.create_stretch(), + spacing=8 + ), + u.create_row( + u.create_label(text=_("Width"), width=130), u.create_line_edit( placeholder_text="@binding(model.width, converter=_float_to_string_converter)", - text="@binding(model.width_text)" + text="@binding(model.width_text)", + width=100 ), - spacing=12 + u.create_stretch(), + spacing=8 ), u.create_row( - u.create_label(text=_("Height:"), width=80), + u.create_label(text=_("Height"), width=130), u.create_line_edit( placeholder_text="@binding(model.height, converter=_float_to_string_converter)", - text="@binding(model.height_text)" + text="@binding(model.height_text)", + width=100 ), - spacing=12 + u.create_stretch(), + spacing=8 ), u.create_row( - u.create_label(text=_("Units:"), width=80), + u.create_label(text=_("Units"), width=130), u.create_combo_box( items=[_("Pixels"), _("Inches"), _("Centimeters")], current_index="@binding(model.units)", + width=100 ), - spacing=12 + u.create_stretch(), + spacing=8 ), - spacing=12, - margin=12 + spacing=8, + margin=12, + width=300 )