コード例 #1
0
 def __get_calculated_data(self, ui):
     drawing_context, shape = DisplayPanel.preview(
         DisplayPanel.DisplayPanelUISettings(ui), self.__display_item, 512,
         512)
     thumbnail_drawing_context = DrawingContext.DrawingContext()
     thumbnail_drawing_context.scale(self.width / 512, self.height / 512)
     thumbnail_drawing_context.translate(0, (shape[1] - shape[0]) * 0.5)
     thumbnail_drawing_context.add(drawing_context)
     return ui.create_rgba_image(thumbnail_drawing_context, self.width,
                                 self.height)
コード例 #2
0
    def register_hardware_panel(hardware_source):
        if hardware_source.features.get("is_video", False):
            panel_id = "video-control-panel-" + hardware_source.hardware_source_id
            hardware_control_panels[hardware_source.hardware_source_id] = panel_id

            class HardwareDisplayPanelControllerFactory:
                def __init__(self):
                    self.priority = 1

                def build_menu(self, display_type_menu, selected_display_panel):
                    # return a list of actions that have been added to the menu.
                    def switch_to_live_controller(hardware_source):
                        d = {"type": "image", "controller_type": VideoDisplayPanelController.type, "hardware_source_id": hardware_source.hardware_source_id}
                        selected_display_panel.change_display_panel_content(d)

                    action = display_type_menu.add_menu_item(hardware_source.display_name, functools.partial(switch_to_live_controller, hardware_source))
                    action.checked = False
                    return [action]

                def make_new(self, controller_type, display_panel, d):
                    # make a new display panel controller, typically called to restore contents of a display panel.
                    # controller_type will match the type property of the display panel controller when it was saved.
                    # d is the dictionary that is saved when the display panel controller closes.
                    hardware_source_id = d.get("hardware_source_id")
                    if controller_type == VideoDisplayPanelController.type and hardware_source_id == hardware_source.hardware_source_id:
                        return VideoDisplayPanelController(display_panel, hardware_source_id)
                    return None

                def match(self, document_model, data_item):
                    if HardwareSource.matches_hardware_source(hardware_source.hardware_source_id, None, document_model, data_item):
                        return {"controller_type": VideoDisplayPanelController.type, "hardware_source_id": hardware_source.hardware_source_id}
                    return None

            DisplayPanel.DisplayPanelManager().register_display_panel_controller_factory("video-live-" + hardware_source.hardware_source_id, HardwareDisplayPanelControllerFactory())
コード例 #3
0
ファイル: HistogramPanel.py プロジェクト: meyer9/nionswift
        def set_display_limits(display_limits):
            # display_limits in this context are in the range of 0,1
            # we ask for the display_range from the display to get actual
            # data values (never None), and create new display limits
            # based on those data values combined with display_limits.
            # then we set the display_limits on the display, which have
            # the same units as the data values.
            display_item = self.__display_item_stream.value
            display_data_channel = display_item.display_data_channel if display_item else None
            if display_data_channel:
                new_display_limits = None
                if display_limits is not None and self.__display_range is not None:
                    data_min, data_max = self.__display_range
                    lower_display_limit = data_min + display_limits[0] * (
                        data_max - data_min)
                    upper_display_limit = data_min + display_limits[1] * (
                        data_max - data_min)
                    new_display_limits = (lower_display_limit,
                                          upper_display_limit)

                command = DisplayPanel.ChangeDisplayDataChannelCommand(
                    document_controller.document_model,
                    display_data_channel,
                    display_limits=new_display_limits,
                    title=_("Change Display Limits"))
                command.perform()
                document_controller.push_undo_command(command)
コード例 #4
0
 def update_pressed():
     display_script = text_edit.text if text_edit.text else None
     command = DisplayPanel.ChangeDisplayCommand(
         document_controller.document_model,
         display_item,
         title=_("Change Display Script"),
         display_script=display_script)
     command.perform()
     document_controller.push_undo_command(command)
コード例 #5
0
 def unregister_hardware_panel(hardware_source):
     if hardware_source.features.get("is_video", False):
         DisplayPanel.DisplayPanelManager().unregister_display_panel_controller_factory("video-live-" + hardware_source.hardware_source_id)
コード例 #6
0
    def register_hardware_panel(
            hardware_source: HardwareSource.HardwareSource) -> None:
        if hardware_source.features.get("is_video", False):
            panel_id = "video-control-panel-" + hardware_source.hardware_source_id
            hardware_control_panels[
                hardware_source.hardware_source_id] = panel_id

            class HardwareDisplayPanelControllerFactory:
                def __init__(self) -> None:
                    self.priority = 1

                def build_menu(
                    self, display_type_menu: UserInterface.Menu,
                    selected_display_panel: typing.Optional[
                        DisplayPanel.DisplayPanel]
                ) -> typing.Sequence[UserInterface.MenuAction]:
                    # return a list of actions that have been added to the menu.
                    def switch_to_live_controller(
                        hardware_source: video_base.VideoHardwareSource
                    ) -> None:
                        d = {
                            "type":
                            "image",
                            "controller_type":
                            VideoDisplayPanelController.type,
                            "hardware_source_id":
                            hardware_source.hardware_source_id
                        }
                        if selected_display_panel:
                            selected_display_panel.change_display_panel_content(
                                d)

                    action = display_type_menu.add_menu_item(
                        hardware_source.display_name,
                        functools.partial(switch_to_live_controller,
                                          hardware_source))
                    display_panel_controller = selected_display_panel.display_panel_controller if selected_display_panel else None
                    action.checked = isinstance(
                        display_panel_controller, VideoDisplayPanelController
                    ) and display_panel_controller.hardware_source_id == hardware_source.hardware_source_id
                    return [action]

                def make_new(
                    self, controller_type: str,
                    display_panel: DisplayPanel.DisplayPanel,
                    d: Persistence.PersistentDictType
                ) -> typing.Optional[VideoDisplayPanelController]:
                    # make a new display panel controller, typically called to restore contents of a display panel.
                    # controller_type will match the type property of the display panel controller when it was saved.
                    # d is the dictionary that is saved when the display panel controller closes.
                    hardware_source_id = d.get("hardware_source_id")
                    if controller_type == VideoDisplayPanelController.type and hardware_source_id == hardware_source.hardware_source_id:
                        return VideoDisplayPanelController(
                            display_panel, hardware_source_id)
                    return None

                def match(
                    self, document_model: DocumentModel.DocumentModel,
                    data_item: DataItem.DataItem
                ) -> typing.Optional[Persistence.PersistentDictType]:
                    if HardwareSource.matches_hardware_source(
                            hardware_source.hardware_source_id, None,
                            document_model, data_item):
                        return {
                            "controller_type":
                            VideoDisplayPanelController.type,
                            "hardware_source_id":
                            hardware_source.hardware_source_id
                        }
                    return None

            DisplayPanel.DisplayPanelManager(
            ).register_display_panel_controller_factory(
                "video-live-" + hardware_source.hardware_source_id,
                HardwareDisplayPanelControllerFactory())