Пример #1
0
    def __init__(self, parent, start_callback=None, exit_callback=None):
        wx.Panel.__init__(self, parent)  # , style=wx.RAISED_BORDER)

        self.start_callback = start_callback
        self.exit_callback = exit_callback

        # Elements
        self.video_page = VideoPage(self, title=_('Scanner autocheck'),
                                    start_callback=self.on_start,
                                    cancel_callback=self.on_cancel)

        # Layout
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(self.video_page, 1, wx.ALL | wx.EXPAND, 0)
        self.SetSizer(hbox)

        self._initialize()
        self.Layout()
Пример #2
0
    def __init__(self, parent, start_callback=None, exit_callback=None):
        wx.Panel.__init__(self, parent)  # , style=wx.RAISED_BORDER)

        self.start_callback = start_callback
        self.exit_callback = exit_callback

        self.video_page = VideoPage(self,
                                    title=_('Laser triangulation'),
                                    start_callback=self.on_start,
                                    cancel_callback=self.on_exit)
        self.result_page = ResultPage(self, exit_callback=self.on_exit)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(self.video_page, 1, wx.ALL | wx.EXPAND, 0)
        hbox.Add(self.result_page, 1, wx.ALL | wx.EXPAND, 0)
        self.SetSizer(hbox)
        self.Layout()

        self._initialize()
Пример #3
0
class LaserTriangulationPages(wx.Panel):
    def __init__(self, parent, start_callback=None, exit_callback=None):
        wx.Panel.__init__(self, parent)  # , style=wx.RAISED_BORDER)

        self.start_callback = start_callback
        self.exit_callback = exit_callback

        self.video_page = VideoPage(self,
                                    title=_('Laser triangulation'),
                                    start_callback=self.on_start,
                                    cancel_callback=self.on_exit)
        self.result_page = ResultPage(self, exit_callback=self.on_exit)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(self.video_page, 1, wx.ALL | wx.EXPAND, 0)
        hbox.Add(self.result_page, 1, wx.ALL | wx.EXPAND, 0)
        self.SetSizer(hbox)
        self.Layout()

        self._initialize()

    def _initialize(self):
        self.video_page.initialize()
        self.result_page.Hide()
        self.video_page.Show()
        self.video_page.play()
        self.video_page.right_button.Enable()
        self.GetParent().Layout()
        self.Layout()

    def play(self):
        self.video_page.play()

    def stop(self):
        self.video_page.stop()

    def reset(self):
        self.video_page.reset()

    def before_calibration(self):
        if self.start_callback is not None:
            self.start_callback()
        self.video_page.right_button.Disable()
        if not hasattr(self, 'wait_cursor'):
            self.wait_cursor = wx.BusyCursor()

    def progress_calibration(self, progress):
        self.video_page.gauge.SetValue(progress)

    def after_calibration(self, response):
        ret, result = response
        if ret:
            self.video_page.Hide()
            self.video_page.stop()
            self.result_page.Show()
            self.Layout()
        else:
            self.on_exit()
        self.result_page.process_calibration(response)
        if hasattr(self, 'wait_cursor'):
            del self.wait_cursor

    def on_start(self):
        laser_triangulation.set_callbacks(
            lambda: wx.CallAfter(self.before_calibration),
            lambda p: wx.CallAfter(self.progress_calibration, p),
            lambda r: wx.CallAfter(self.after_calibration, r))
        laser_triangulation.start()

    def on_exit(self):
        laser_triangulation.cancel()
        self._initialize()
        if self.exit_callback is not None:
            self.exit_callback()
Пример #4
0
class ScannerAutocheckPages(wx.Panel):

    def __init__(self, parent, start_callback=None, exit_callback=None):
        wx.Panel.__init__(self, parent)  # , style=wx.RAISED_BORDER)

        self.start_callback = start_callback
        self.exit_callback = exit_callback

        # Elements
        self.video_page = VideoPage(self, title=_('Scanner autocheck'),
                                    start_callback=self.on_start,
                                    cancel_callback=self.on_cancel)

        # Layout
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(self.video_page, 1, wx.ALL | wx.EXPAND, 0)
        self.SetSizer(hbox)

        self._initialize()
        self.Layout()

    def _initialize(self):
        self.video_page.initialize()

    def play(self):
        self.video_page.play()

    def stop(self):
        self.video_page.stop()

    def reset(self):
        self.video_page.reset()

    def before_calibration(self):
        if self.start_callback is not None:
            self.start_callback()
        self.video_page.right_button.Disable()
        if not hasattr(self, 'wait_cursor'):
            self.wait_cursor = wx.BusyCursor()

    def progress_calibration(self, progress):
        self.video_page.gauge.SetValue(progress)

    def after_calibration(self, response):
        ret, result = response

        # Flush video
        image_capture.capture_pattern()
        image_capture.capture_pattern()

        if ret:
            dlg = wx.MessageDialog(
                self, _("Scanner configured correctly"),
                str(_("Success")), wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()
        else:
            if isinstance(result, PatternNotDetected):
                dlg = wx.MessageDialog(
                    self, _("Please, put the pattern on the platform. "
                            "Also you can set up the calibration's capture "
                            "settings in the \"Adjustment workbench\" "
                            "until the pattern is detected correctly"),
                    str(_(result)), wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()
            elif isinstance(result, WrongMotorDirection):
                dlg = wx.MessageDialog(
                    self, _(
                        "Please, select \"Invert the motor direction\" in the preferences"),
                    str(_(result)), wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()
                self.GetParent().GetParent().launch_preferences(basic=True)
            elif isinstance(result, LaserNotDetected):
                dlg = wx.MessageDialog(
                    self, _("Please, check the lasers connection. "
                            "Also you can set up the calibration's capture and "
                            "segmentation settings in the \"Adjustment workbench\" "
                            "until the lasers are detected correctly"),
                    str(_(result)), wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()
        self._initialize()
        self.video_page.right_button.Enable()
        if hasattr(self, 'wait_cursor'):
            del self.wait_cursor
        if self.exit_callback is not None:
            self.exit_callback()

    def on_start(self):
        scanner_autocheck.set_callbacks(lambda: wx.CallAfter(self.before_calibration),
                                        lambda p: wx.CallAfter(self.progress_calibration, p),
                                        lambda r: wx.CallAfter(self.after_calibration, r))
        scanner_autocheck.start()

    def on_cancel(self):
        self._initialize()
        self.video_page.right_button.Enable()
        scanner_autocheck.cancel()
        if hasattr(self, 'wait_cursor'):
            del self.wait_cursor
        if self.exit_callback is not None:
            self.exit_callback()