def _set_mode_layout(self, mode): if mode == 'Laser': self.get_control('brightness_pattern_calibration').Hide() self.get_control('contrast_pattern_calibration').Hide() self.get_control('saturation_pattern_calibration').Hide() self.get_control('exposure_pattern_calibration').Hide() self.get_control('brightness_laser_calibration').Show() self.get_control('contrast_laser_calibration').Show() self.get_control('saturation_laser_calibration').Show() self.get_control('exposure_laser_calibration').Show() self.get_control('remove_background_calibration').Show() elif mode == 'Pattern': self.get_control('brightness_pattern_calibration').Show() self.get_control('contrast_pattern_calibration').Show() self.get_control('saturation_pattern_calibration').Show() self.get_control('exposure_pattern_calibration').Show() self.get_control('brightness_laser_calibration').Hide() self.get_control('contrast_laser_calibration').Hide() self.get_control('saturation_laser_calibration').Hide() self.get_control('exposure_laser_calibration').Hide() self.get_control('remove_background_calibration').Hide() if sys.is_wx30(): self.content.SetSizerAndFit(self.content.vbox) if sys.is_windows(): self.parent.Refresh() self.parent.Layout() self.Layout()
def update_workbench(self, name): self.wait_cursor = wx.BusyCursor() self.toolbar.combo.SetValue(name) if sys.is_windows(): for key, wb in self.workbench.iteritems(): if wb.name == name: wb.Show() profile.settings['workbench'] = key for key, wb in self.workbench.iteritems(): if wb.name != name: wb.Hide() else: for key, wb in self.workbench.iteritems(): if wb.name != name: wb.Hide() for key, wb in self.workbench.iteritems(): if wb.name == name: wb.Show() profile.settings['workbench'] = key is_scan = profile.settings['workbench'] == 'scanning' self.menu_file.Enable(self.menu_load_model.GetId(), is_scan) self.menu_file.Enable(self.menu_save_model.GetId(), is_scan) self.menu_file.Enable(self.menu_clear_model.GetId(), is_scan) self.toolbar.scanning_mode(is_scan) profile.settings.save_settings() self.Layout() del self.wait_cursor gc.collect()
def _set_mode_layout(self, mode): if mode == 'Laser': self.get_control('brightness_texture_scanning').Hide() self.get_control('contrast_texture_scanning').Hide() self.get_control('saturation_texture_scanning').Hide() self.get_control('exposure_texture_scanning').Hide() self.get_control('brightness_laser_scanning').Show() self.get_control('contrast_laser_scanning').Show() self.get_control('saturation_laser_scanning').Show() self.get_control('exposure_laser_scanning').Show() self.get_control('remove_background_scanning').Show() elif mode == 'Texture': self.get_control('brightness_texture_scanning').Show() self.get_control('contrast_texture_scanning').Show() self.get_control('saturation_texture_scanning').Show() self.get_control('exposure_texture_scanning').Show() self.get_control('brightness_laser_scanning').Hide() self.get_control('contrast_laser_scanning').Hide() self.get_control('saturation_laser_scanning').Hide() self.get_control('exposure_laser_scanning').Hide() self.get_control('remove_background_scanning').Hide() if sys.is_wx30(): self.content.SetSizerAndFit(self.content.vbox) if sys.is_windows(): self.parent.Refresh() self.parent.Layout() self.Layout()
def __init__(self, protocol="arduino", microcontroller="atmega328p", baud_rate="19200", port=None): self.protocol = protocol self.microcontroller = microcontroller self.baud_rate = baud_rate if sys.is_windows(): self.avrdude = os.path.abspath( resources.get_path_for_tools("avrdude.exe")) elif sys.is_darwin(): self.avrdude = os.path.abspath( resources.get_path_for_tools("avrdude")) else: try: Popen(["avrdude"], stdout=PIPE, stderr=STDOUT) self.avrdude = "avrdude" except: self.avrdude = None if self.avrdude is None: raise AvrError('avrdude not installed') self.avrconf = os.path.abspath( resources.get_path_for_tools("avrdude.conf")) self.port = port
def on_calibration_page_next_clicked(self): if sys.is_windows(): self.scanning_page.Show() self.calibration_page.Hide() else: self.calibration_page.Hide() self.scanning_page.Show() self.Layout()
def on_calibration_page_prev_clicked(self): if sys.is_windows(): self.connection_page.Show() self.calibration_page.Hide() else: self.calibration_page.Hide() self.connection_page.Show() self.Layout()
def get_path_for_tools(name): if system.is_windows(): path = get_path_for_resource('tools/windows', name) elif system.is_darwin(): path = get_path_for_resource('tools/darwin', name) else: path = get_path_for_resource('tools/linux', name) return path
def after_connect(self, response): ret, result = response if not ret: if isinstance(result, WrongFirmware): self._show_message( _(result), wx.ICON_INFORMATION, _("The board has the wrong firmware or an invalid baud rate.\n" "Please select your board and press \"Upload firmware\"") ) self.update_status(False) self.GetParent().launch_preferences() elif isinstance(result, BoardNotConnected): self._show_message( _(result), wx.ICON_INFORMATION, _("The board is not connected.\n" "Please connect your board and select a valid Serial name" )) self.update_status(False) self.GetParent().launch_preferences(basic=True) elif isinstance(result, OldFirmware): self._show_message( _(result), wx.ICON_INFORMATION, _("The board has and old firmware.\n" "Please select your board and press \"Upload firmware\"") ) self.update_status(False) self.GetParent().launch_preferences() elif isinstance(result, WrongCamera): self._show_message( _(result), wx.ICON_INFORMATION, _("You probably have selected the wrong camera.\n" "Please select another Camera ID")) self.update_status(False) self.GetParent().launch_preferences(basic=True) elif isinstance(result, CameraNotConnected): self._show_message( _(result), wx.ICON_ERROR, _("Please plug your camera in and try to connect again")) elif isinstance(result, InvalidVideo): self._show_message( _(result), wx.ICON_ERROR, _("Unplug and plug your camera USB cable " "and try to connect again")) elif isinstance(result, WrongDriver): if system.is_windows(): self._show_message( _(result), wx.ICON_ERROR, _("Please, download and install the camera driver: \n" "http://support.logitech.com/en_us/product/hd-webcam-c270" )) self.update_status(driver.is_connected) self.GetParent().enable_gui(True) del self.wait_cursor
def _expand_callback(self, selected_panel): if sys.is_windows(): selected_panel.show_content() for panel in list(self.expandable_panels.values()): if panel is not selected_panel: panel.hide_content() else: for panel in list(self.expandable_panels.values()): if panel is not selected_panel: panel.hide_content() selected_panel.show_content()
def __init__(self, parent): if sys.is_windows(): size = (760, 540) else: size = (760, 520) super(Wizard, self).__init__(parent, title="", size=size) self.parent = parent self.connection_page = ConnectionPage( self, button_prev_callback=self.on_connection_page_prev_clicked, button_next_callback=self.on_connection_page_next_clicked) self.calibration_page = CalibrationPage( self, button_prev_callback=self.on_calibration_page_prev_clicked, button_next_callback=self.on_calibration_page_next_clicked) self.scanning_page = ScanningPage( self, button_prev_callback=self.on_scanning_page_prev_clicked, button_next_callback=self.on_scanning_page_next_clicked) pages = [ self.connection_page, self.calibration_page, self.scanning_page ] self.connection_page.intialize(pages) self.calibration_page.intialize(pages) self.scanning_page.intialize(pages) self.connection_page.Show() self.calibration_page.Hide() self.scanning_page.Hide() driver.board.set_unplug_callback( lambda: wx.CallAfter(self.on_board_unplugged)) driver.camera.set_unplug_callback( lambda: wx.CallAfter(self.on_camera_unplugged)) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.connection_page, 1, wx.ALL | wx.EXPAND, 0) hbox.Add(self.calibration_page, 1, wx.ALL | wx.EXPAND, 0) hbox.Add(self.scanning_page, 1, wx.ALL | wx.EXPAND, 0) self.SetSizer(hbox) self.Bind(wx.EVT_CLOSE, lambda e: self.on_exit()) self.Centre() self.ShowModal()
def _run_command(self, flags=[], callback=None): config = dict(avrdude=self.avrdude, avrconf=self.avrconf) cmd = ['%(avrdude)s'] + flags cmd = [v % config for v in cmd] logger.info(' ' + ' '.join(cmd)) p = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=sys.is_windows()) out = '' while True: char = p.stdout.read(1) if not char: break out += char if char == '#': if callback is not None: callback() return out
def get_base_path(): """ :return: The path in which the current configuration files are stored. This depends on the used OS. """ if system.is_windows(): basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) # If we have a frozen python install, we need to step out of the library.zip if hasattr(sys, 'frozen'): basePath = os.path.normpath(os.path.join(basePath, "..")) else: basePath = os.path.expanduser('~/.horus/') if not os.path.isdir(basePath): try: os.makedirs(basePath) except: logger.error("Failed to create directory: %s" % (basePath)) return basePath
def initialize_driver(self): # Serial name serial_list = driver.board.get_serial_list() current_serial = profile.settings['serial_name'] if len(serial_list) > 0: if current_serial not in serial_list: profile.settings['serial_name'] = serial_list[0] # Video id video_list = driver.camera.get_video_list() current_video_id = profile.settings['camera_id'] if len(video_list) > 0: if current_video_id not in video_list: profile.settings['camera_id'] = unicode(video_list[0]) if len(profile.settings['camera_id']): driver.camera.camera_id = int(profile.settings['camera_id'][-1:]) driver.board.serial_name = profile.settings['serial_name'] driver.board.baud_rate = profile.settings['baud_rate'] driver.board.motor_invert(profile.settings['invert_motor']) platform_extrinsics.set_estimated_size( profile.settings['estimated_size']) flush_setting = 'flush_' flush_stream_setting = 'flush_stream_' if sys.is_linux(): flush_setting += 'linux' flush_stream_setting += 'linux' elif sys.is_darwin(): flush_setting += 'darwin' flush_stream_setting += 'darwin' elif sys.is_windows(): flush_setting += 'windows' flush_stream_setting += 'windows' texture, laser, pattern = profile.settings[flush_setting] image_capture.set_flush_values(texture, laser, pattern) texture, laser, pattern = profile.settings[flush_stream_setting] image_capture.set_flush_stream_values(texture, laser, pattern)
def _get_executable_url(version): url = None if sys.is_linux(): import platform url = 'https://launchpad.net/~bqlabs/+archive/ubuntu/horus/+files/' url += 'horus_' url += version + '-' url += platform.linux_distribution()[2] + '1_' if platform.architecture()[0] == '64bit': url += 'amd64.deb' elif platform.architecture()[0] == '32bit': url += 'i386.deb' del platform elif sys.is_windows(): url = URL_DOWNLOAD url += latest_version url += '/Horus_' url += version + '.exe' elif sys.is_darwin(): url = URL_DOWNLOAD url += latest_version url += '/Horus_' url += version + '.dmg' return url