def updateDriverProfile(self): self.driver.camera.setCameraId( int(profile.getProfileSetting('camera_id')[-1:])) self.driver.board.setSerialName( profile.getProfileSetting('serial_name')) self.driver.board.setBaudRate( profile.getProfileSettingInteger('baud_rate'))
def onPlayToolClicked(self, event): if self.currentScan.inactive: #-- Resume self.enableLabelTool(self.pauseTool , True) self.enableLabelTool(self.playTool, False) self.currentScan.resume() self.pointCloudTimer.Start(milliseconds=50) else: result = True if self.sceneView._object is not None: dlg = wx.MessageDialog(self, _("Your current model will be erased.\nDo you really want to do it?"), _("Clear Point Cloud"), wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal() == wx.ID_YES dlg.Destroy() if result: value = profile.getProfileSetting('scan_type') if value == 'Simple Scan': self.currentScan = self.simpleScan elif value == 'Texture Scan': self.currentScan = self.textureScan self.gauge.SetValue(0) self.gauge.Show() self.scenePanel.Layout() self.Layout() self.currentScan.setCallbacks(self.beforeScan, lambda r: wx.CallAfter(self.afterScan,r)) self.currentScan.start()
def __init__(self, parent): """""" ExpandablePanel.__init__(self, parent, _("Image Acquisition")) self.driver = Driver.Instance() self.pcg = PointCloudGenerator.Instance() self.simpleScan = SimpleScan.Instance() self.textureScan = TextureScan.Instance() self.main = self.GetParent().GetParent().GetParent().GetParent() self.last_resolution = profile.getProfileSetting('resolution_scanning') self.clearSections() section = self.createSection('camera_scanning') section.addItem(Slider, 'brightness_scanning', tooltip=_('Image luminosity. Low values are better for environments with high ambient light conditions. High values are recommended for poorly lit places')) section.addItem(Slider, 'contrast_scanning', tooltip=_('Relative difference in intensity between an image point and its surroundings. Low values are recommended for black or very dark colored objects. High values are better for very light colored objects')) section.addItem(Slider, 'saturation_scanning', tooltip=_('Purity of color. Low values will cause colors to disappear from the image. High values will show an image with very intense colors')) section.addItem(Slider, 'laser_exposure_scanning', tooltip=_('Amount of light per unit area. It is controlled by the time the camera sensor is exposed during a frame capture. High values are recommended for poorly lit places')) section.addItem(Slider, 'color_exposure_scanning', tooltip=_('Amount of light per unit area. It is controlled by the time the camera sensor is exposed during a frame capture. High values are recommended for poorly lit places')) section.addItem(ComboBox, 'framerate_scanning', tooltip=_('Number of frames captured by the camera every second. Maximum frame rate is recommended')) section.addItem(ComboBox, 'resolution_scanning', tooltip=_('Size of the video. Maximum resolution is recommended')) section.addItem(CheckBox, 'use_distortion_scanning', tooltip=_("This option applies lens distortion correction to the video. This process slows the video feed from the camera")) if sys.isDarwin(): section = self.sections['camera_scanning'].disable('framerate_scanning') section = self.sections['camera_scanning'].disable('resolution_scanning')
def onPlayToolClicked(self, event): if self.currentScan.inactive: #-- Resume self.enableLabelTool(self.pauseTool, True) self.enableLabelTool(self.playTool, False) self.currentScan.resume() self.pointCloudTimer.Start(milliseconds=50) else: result = True if self.sceneView._object is not None: dlg = wx.MessageDialog( self, _("Your current model will be erased.\nDo you really want to do it?" ), _("Clear Point Cloud"), wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal() == wx.ID_YES dlg.Destroy() if result: value = profile.getProfileSetting('scan_type') print value if value == _("Without Texture"): self.currentScan = self.simpleScan self.driver.camera.setExposure( profile.getProfileSettingInteger( 'laser_exposure_scanning')) elif value == _("With Texture"): self.currentScan = self.textureScan self.driver.camera.setExposure( profile.getProfileSettingInteger( 'color_exposure_scanning')) self.currentScan.setCallbacks( self.beforeScan, None, lambda r: wx.CallAfter(self.afterScan, r)) self.currentScan.start()
def __init__(self, parent): """""" ExpandablePanel.__init__(self, parent, _("Scan Parameters"), hasUndo=False, hasRestore=False) self.driver = Driver.Instance() self.simpleScan = SimpleScan.Instance() self.textureScan = TextureScan.Instance() self.pcg = PointCloudGenerator.Instance() self.main = self.GetParent().GetParent().GetParent().GetParent() self.parent = parent self.lastScan = profile.getProfileSetting('scan_type') self.clearSections() section = self.createSection('scan_parameters') section.addItem( ComboBox, 'scan_type', tooltip= _("Simple Scan algorithm captures only the geometry using one image. Texture Scan algorithm captures also the texture using two images" )) section.addItem(ComboBox, 'use_laser') if os.name != 'nt': section.addItem(CheckBox, 'fast_scan')
def __init__(self, parent, name, engineCallback=None): """ """ SectionItem.__init__(self, parent, name, engineCallback) _choices = [] choices = self.setting.getType() for i in choices: _choices.append(_(i)) self.keyDict = dict(zip(_choices, choices)) #-- Elements self.label = wx.StaticText(self, label=self.setting.getLabel()) self.control = wx.ComboBox(self, wx.ID_ANY, value=_(profile.getProfileSetting(self.name)), choices=_choices, size=(1, -1), style=wx.CB_READONLY) #-- Layout hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.label, 0, wx.TOP|wx.RIGHT|wx.EXPAND, 18) hbox.Add(self.control, 1, wx.TOP|wx.RIGHT|wx.EXPAND, 12) self.SetSizer(hbox) self.Layout() #-- Events self.control.Bind(wx.EVT_COMBOBOX, self.onComboBoxChanged)
def setResolution(self, value): if value != self.last_resolution: ResolutionWindow(self) self.driver.camera.setResolution(int(value.split('x')[0]), int(value.split('x')[1])) self.last_resolution = profile.getProfileSetting( 'resolution_calibration')
def onPlayToolClicked(self, event): if self.currentScan.inactive: #-- Resume self.enableLabelTool(self.pauseTool, True) self.enableLabelTool(self.playTool, False) self.currentScan.resume() self.pointCloudTimer.Start(milliseconds=50) else: result = True if self.sceneView._object is not None: dlg = wx.MessageDialog( self, _("Your current model will be erased.\nDo you really want to do it?" ), _("Clear Point Cloud"), wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal() == wx.ID_YES dlg.Destroy() if result: value = profile.getProfileSetting('scan_type') if value == 'Simple Scan': self.currentScan = self.simpleScan elif value == 'Texture Scan': self.currentScan = self.textureScan self.gauge.SetValue(0) self.gauge.Show() self.scenePanel.Layout() self.Layout() self.currentScan.setCallbacks( self.beforeScan, lambda r: wx.CallAfter(self.afterScan, r)) self.currentScan.start()
def __init__(self, parent, name, engineCallback=None, dropdown= None): """ """ SectionItem.__init__(self, parent, name, engineCallback) _choices=self.setting.getType() choices=[] if dropdown != None: for i in _choices: choices.append(_(i)) else: choices = _choices #-- Elements self.label = wx.StaticText(self, label=self.setting.getLabel()) self.control = wx.ComboBox(self, wx.ID_ANY, value=profile.getProfileSetting(self.name), choices=choices, size=(150, -1), style=wx.CB_READONLY) #-- Layout hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.label, 0, wx.TOP|wx.RIGHT|wx.EXPAND, 18) hbox.Add(self.control, 1, wx.TOP|wx.RIGHT|wx.EXPAND, 12) self.SetSizer(hbox) self.Layout() #-- Events self.control.Bind(wx.EVT_COMBOBOX, self.onComboBoxChanged)
def __init__(self, parent): """""" ExpandablePanel.__init__(self, parent, _("Image Acquisition")) self.driver = Driver.Instance() self.pcg = PointCloudGenerator.Instance() self.simpleScan = SimpleScan.Instance() self.textureScan = TextureScan.Instance() self.main = self.GetParent().GetParent().GetParent().GetParent() self.last_resolution = profile.getProfileSetting('resolution_scanning') self.clearSections() section = self.createSection('camera_scanning') section.addItem( Slider, 'brightness_scanning', tooltip= _('Image luminosity. Low values are better for environments with high ambient light conditions. High values are recommended for poorly lit places' )) section.addItem( Slider, 'contrast_scanning', tooltip= _('Relative difference in intensity between an image point and its surroundings. Low values are recommended for black or very dark colored objects. High values are better for very light colored objects' )) section.addItem( Slider, 'saturation_scanning', tooltip= _('Purity of color. Low values will cause colors to disappear from the image. High values will show an image with very intense colors' )) section.addItem( Slider, 'laser_exposure_scanning', tooltip= _('Amount of light per unit area. It is controlled by the time the camera sensor is exposed during a frame capture. High values are recommended for poorly lit places' )) section.addItem( Slider, 'color_exposure_scanning', tooltip= _('Amount of light per unit area. It is controlled by the time the camera sensor is exposed during a frame capture. High values are recommended for poorly lit places' )) section.addItem( ComboBox, 'framerate_scanning', tooltip= _('Number of frames captured by the camera every second. Maximum frame rate is recommended' )) section.addItem( ComboBox, 'resolution_scanning', tooltip=_('Size of the video. Maximum resolution is recommended')) section.addItem( CheckBox, 'use_distortion_scanning', tooltip= _("This option applies lens distortion correction to the video. This process slows the video feed from the camera" ))
def onTextBoxChanged(self, event): self.undoValues.append(profile.getProfileSetting(self.name)) value = self.control.GetValue() profile.putProfileSetting(self.name, value) self._updateEngine(value) if self.appendUndoCallback is not None: self.appendUndoCallback(self) if self.releaseUndoCallback is not None: self.releaseUndoCallback()
def loadFirmware(self, hexBaudRate, clearEEPROM): avr_dude = AvrDude(port=profile.getProfileSetting('serial_name'), baudRate=hexBaudRate) extraFlags = [] if clearEEPROM: extraFlags = ["-D"] self.count = -50 out = avr_dude.flash(extraFlags=extraFlags, hexPath=self.hexPath, callback=self.incrementProgress) if 'not in sync' in out or 'Invalid' in out: wx.CallAfter(self.wrongBoardMessage) wx.CallAfter(self.afterLoadFirmware)
def __init__(self, parent, buttonPrevCallback=None, buttonNextCallback=None): WizardPage.__init__(self, parent, title=_("Connection"), buttonPrevCallback=buttonPrevCallback, buttonNextCallback=buttonNextCallback) self.parent = parent self.driver = Driver.Instance() self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.autoCheck = calibration.SimpleLaserTriangulation.Instance() self.connectButton = wx.Button(self.panel, label=_("Connect")) luminosity=profile.getProfileSettingObject('luminosity').getType() self.luminosityComboBox = wx.ComboBox(self.panel, wx.ID_ANY, value=profile.getProfileSetting('luminosity'), choices=[_(luminosity[0]), _(luminosity[1]), _(luminosity[2])], style=wx.CB_READONLY) self.patternLabel = wx.StaticText(self.panel, label=_("Put the pattern on the platform and press \"Auto check\"")) self.imageView = ImageView(self.panel) self.imageView.setImage(wx.Image(resources.getPathForImage("pattern-position-right.jpg"))) self.autoCheckButton = wx.Button(self.panel, label=_("Auto check")) self.gauge = wx.Gauge(self.panel, range=100, size=(-1, 30)) self.resultLabel = wx.StaticText(self.panel, size=(-1, 30)) self.connectButton.Enable() self.patternLabel.Disable() self.imageView.Disable() self.autoCheckButton.Disable() self.skipButton.Disable() self.nextButton.Disable() self.resultLabel.Hide() self.enableNext = False vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.connectButton, 1, wx.ALL|wx.EXPAND, 5) hbox.Add(self.luminosityComboBox, 0, wx.ALL|wx.EXPAND, 5) vbox.Add(hbox, 0, wx.ALL|wx.EXPAND, 2) vbox.Add(self.patternLabel, 0, wx.ALL|wx.CENTER, 5) vbox.Add(self.imageView, 1, wx.ALL|wx.EXPAND, 5) vbox.Add(self.resultLabel, 0, wx.ALL|wx.CENTER, 5) vbox.Add(self.gauge, 0, wx.ALL|wx.EXPAND, 5) vbox.Add(self.autoCheckButton, 0, wx.ALL|wx.EXPAND, 5) self.panel.SetSizer(vbox) self.Layout() self.connectButton.Bind(wx.EVT_BUTTON, self.onConnectButtonClicked) self.luminosityComboBox.Bind(wx.EVT_COMBOBOX, self.onLuminosityComboBoxChanged) self.autoCheckButton.Bind(wx.EVT_BUTTON, self.onAutoCheckButtonClicked) self.Bind(wx.EVT_SHOW, self.onShow) self.videoView.setMilliseconds(50) self.videoView.setCallback(self.getDetectChessboardFrame) self.updateStatus(self.driver.isConnected)
def isVisible(self): if profile.getPreferenceBool('basic_mode'): return self.setting.getCategory() is 'basic' else: scanType = profile.getProfileSetting('scan_type') if self.setting.getTag() != None: if scanType == 'Simple Scan': return self.setting.getTag() == 'simple' elif scanType == 'Texture Scan': return self.setting.getTag() == 'texture' else: return True
def updateProfile(self): scanType = profile.getProfileSetting('scan_type') if self.tag != None: if scanType == self.tag: self.Show() else: self.Hide() else: self.Show() for item in self.items.values(): if isinstance(item, tuple): item[0].updateProfile() item[0].label.SetToolTip(wx.ToolTip(item[1])); else: item.updateProfile()
def updateProfile(self): scanType = profile.getProfileSetting('scan_type') if self.tag != None: if scanType == self.tag: self.Show() else: self.Hide() else: self.Show() for item in self.items.values(): if isinstance(item, tuple): item[0].updateProfile() item[0].label.SetToolTip(wx.ToolTip(item[1])) else: item.updateProfile()
def updateStatus(self, status): if status: profile.putPreference('workbench', 'Scanning workbench') self.GetParent().parent.workbenchUpdate(False) self.videoView.play() value = profile.getProfileSetting('use_laser') if value == 'Left': self.driver.board.setLeftLaserOn() self.driver.board.setRightLaserOff() elif value == 'Right': self.driver.board.setLeftLaserOff() self.driver.board.setRightLaserOn() elif value == 'Both': self.driver.board.setLeftLaserOn() self.driver.board.setRightLaserOn() else: self.videoView.stop()
def updateStatus(self, status): if status: profile.putPreference('workbench', 'scanning') self.GetParent().parent.workbenchUpdate(False) self.videoView.play() value = profile.getProfileSetting('use_laser') if value == _("Use Left Laser"): self.driver.board.setLeftLaserOn() self.driver.board.setRightLaserOff() elif value == _("Use Right Laser"): self.driver.board.setLeftLaserOff() self.driver.board.setRightLaserOn() elif value == _("Use Both Laser"): self.driver.board.setLeftLaserOn() self.driver.board.setRightLaserOn() else: self.videoView.stop()
def __init__(self, parent): """""" ExpandablePanel.__init__(self, parent, _("Scan Parameters")) self.driver = Driver.Instance() self.simpleScan = SimpleScan.Instance() self.textureScan = TextureScan.Instance() self.pcg = PointCloudGenerator.Instance() self.main = self.GetParent().GetParent().GetParent().GetParent() self.parent = parent self.lastScan = profile.getProfileSetting('scan_type') self.clearSections() section = self.createSection('scan_parameters') section.addItem(ComboBox, 'scan_type', tooltip=_("Simple Scan algorithm captures only the geometry using one image. Texture Scan algorithm captures also the texture using two images")) section.addItem(ComboBox, 'use_laser') if os.name != 'nt': section.addItem(CheckBox, 'fast_scan')
def __init__(self, parent): super(PatternDistanceWindow, self).__init__(parent, title=_('Pattern distance'), size=(420,-1), style=wx.DEFAULT_FRAME_STYLE^wx.RESIZE_BORDER) self.value = float(profile.getProfileSetting('pattern_distance')) self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.simpleLaserTriangulation = calibration.SimpleLaserTriangulation.Instance() self.laserTriangulation = calibration.LaserTriangulation.Instance() self.platformExtrinsics = calibration.PlatformExtrinsics.Instance() #-- Elements self.description = wx.StaticText(self, label=_('Pattern distance value must be a number higher than 0. Please, change it in the textbox below.')) self.description.Wrap(400) tooltip = _("Minimum distance between the origin of the pattern (bottom-left corner) and the pattern's base surface") self.image = wx.Image(resources.getPathForImage("pattern-distance.jpg"), wx.BITMAP_TYPE_ANY) self.patternImage = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(self.image)) self.patternImage.SetToolTip(wx.ToolTip(tooltip)) self.patternLabel = wx.StaticText(self, label=_('Pattern distance (mm)')) self.patternLabel.SetToolTip(wx.ToolTip(tooltip)) self.patternTextbox = wx.TextCtrl(self, value = str(profile.getProfileSettingFloat('pattern_distance'))) self.okButton = wx.Button(self, label=_('OK')) self.cancelButton = wx.Button(self, label=_('Cancel')) #-- Events self.patternTextbox.Bind(wx.EVT_TEXT, self.onTextBoxChanged) self.cancelButton.Bind(wx.EVT_BUTTON, self.onClose) self.okButton.Bind(wx.EVT_BUTTON, self.onOk) self.Bind(wx.EVT_CLOSE, self.onClose) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.description, 0, wx.ALL|wx.CENTER, 10) vbox.Add(self.patternImage, 0, wx.ALL|wx.CENTER, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.patternLabel, 0, wx.ALL, 7) hbox.Add(self.patternTextbox, 0, wx.ALL, 3) hbox.Add(self.okButton, 0, wx.ALL, 3) hbox.Add(self.cancelButton, 0, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL|wx.CENTER, 10) self.SetSizer(vbox) self.Center() self.Fit() self.ShowModal()
def loadFirmware(self, hexBaudRate, clearEEPROM): avr_dude = AvrDude(port=profile.getProfileSetting('serial_name'), baudRate=hexBaudRate) extraFlags = [] if clearEEPROM: extraFlags = ["-D"] proc = avr_dude.flash(extraFlags=extraFlags) #TODO: fails if change board count = -50 while count < 100: if proc: try: out = proc.stderr.read() if 'not in sync' in out or 'Invalid' in out: wx.CallAfter(self.wrongBoardMessage) break count += out.count('#') if count >= 0: self.gauge.SetValue(count) except IOError: count += 10 wx.CallAfter(self.afterLoadFirmware)
def loadFirmware(self, hexBaudRate, clearEEPROM): avr_dude = AvrDude(port=profile.getProfileSetting('serial_name'), baudRate=hexBaudRate) extraFlags = [] if clearEEPROM: extraFlags = ["-D"] proc = avr_dude.flash( extraFlags=extraFlags) #TODO: fails if change board count = -50 while count < 100: if proc: try: out = proc.stderr.read() if 'not in sync' in out or 'Invalid' in out: wx.CallAfter(self.wrongBoardMessage) break count += out.count('#') if count >= 0: self.gauge.SetValue(count) except IOError: pass wx.CallAfter(self.afterLoadFirmware)
def updatePCGProfile(self): self.pcg.resetTheta() self.pcg.setViewROI(profile.getMachineSettingBool('view_roi')) self.pcg.setROIDiameter(profile.getMachineSettingInteger('roi_diameter')) self.pcg.setROIWidth(profile.getMachineSettingInteger('roi_width')) self.pcg.setROIHeight(profile.getMachineSettingInteger('roi_height')) self.pcg.setROIDepth(profile.getMachineSettingInteger('roi_depth')) self.pcg.setDegrees(profile.getProfileSettingFloat('step_degrees_scanning')) resolution = profile.getProfileSetting('resolution_scanning') self.pcg.setResolution(int(resolution.split('x')[1]), int(resolution.split('x')[0])) useLaser = profile.getProfileSetting('use_laser') self.pcg.setUseLaser(useLaser == 'Left' or useLaser == 'Both', useLaser == 'Right' or useLaser == 'Both') self.pcg.setCameraIntrinsics(profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.pcg.setLaserTriangulation(profile.getProfileSettingNumpy('distance_left'), profile.getProfileSettingNumpy('normal_left'), profile.getProfileSettingNumpy('distance_right'), profile.getProfileSettingNumpy('normal_right')) self.pcg.setPlatformExtrinsics(profile.getProfileSettingNumpy('rotation_matrix'), profile.getProfileSettingNumpy('translation_vector')) scanType = profile.getProfileSetting('scan_type') if scanType == 'Simple Scan': self.scanningWorkbench.currentScan = self.simpleScan self.driver.camera.setExposure(profile.getProfileSettingInteger('laser_exposure_scanning')) elif scanType == 'Texture Scan': self.scanningWorkbench.currentScan = self.textureScan self.driver.camera.setExposure(profile.getProfileSettingInteger('color_exposure_scanning')) self.simpleScan.setFastScan(profile.getProfileSettingBool('fast_scan')) self.simpleScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning')) self.simpleScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning')) self.simpleScan.setImageType(profile.getProfileSetting('img_type')) self.simpleScan.setUseThreshold(profile.getProfileSettingBool('use_cr_threshold')) self.simpleScan.setThresholdValue(profile.getProfileSettingInteger('cr_threshold_value')) self.simpleScan.setColor(struct.unpack('BBB',profile.getProfileSetting('point_cloud_color').decode('hex'))) self.textureScan.setFastScan(profile.getProfileSettingBool('fast_scan')) self.textureScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning')) self.textureScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning')) self.textureScan.setImageType(profile.getProfileSetting('img_type')) self.textureScan.setUseOpen(profile.getProfileSettingBool('use_open')) self.textureScan.setOpenValue(profile.getProfileSettingInteger('open_value')) self.textureScan.setUseThreshold(profile.getProfileSettingBool('use_threshold')) self.textureScan.setThresholdValue(profile.getProfileSettingInteger('threshold_value'))
def updatePCGProfile(self): self.pcg.resetTheta() self.pcg.setViewROI(profile.getProfileSettingBool('view_roi')) self.pcg.setROIDiameter(profile.getProfileSettingInteger('roi_diameter')) self.pcg.setROIHeight(profile.getProfileSettingInteger('roi_height')) self.pcg.setDegrees(profile.getProfileSettingFloat('step_degrees_scanning')) resolution = profile.getProfileSetting('resolution_scanning') self.pcg.setResolution(int(resolution.split('x')[1]), int(resolution.split('x')[0])) useLaser = profile.getProfileSetting('use_laser') self.pcg.setUseLaser(useLaser == 'Left' or useLaser == 'Both', useLaser == 'Right' or useLaser == 'Both') self.pcg.setCameraIntrinsics(profile.getProfileSettingNumpy('camera_matrix'), profile.getProfileSettingNumpy('distortion_vector')) self.pcg.setLaserTriangulation(profile.getProfileSettingNumpy('distance_left'), profile.getProfileSettingNumpy('normal_left'), profile.getProfileSettingNumpy('distance_right'), profile.getProfileSettingNumpy('normal_right')) self.pcg.setPlatformExtrinsics(profile.getProfileSettingNumpy('rotation_matrix'), profile.getProfileSettingNumpy('translation_vector')) scanType = profile.getProfileSetting('scan_type') if scanType == 'Simple Scan': self.scanningWorkbench.currentScan = self.simpleScan self.driver.camera.setExposure(profile.getProfileSettingInteger('laser_exposure_scanning')) elif scanType == 'Texture Scan': self.scanningWorkbench.currentScan = self.textureScan self.driver.camera.setExposure(profile.getProfileSettingInteger('color_exposure_scanning')) self.simpleScan.setFastScan(profile.getProfileSettingBool('fast_scan')) self.simpleScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning')) self.simpleScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning')) self.simpleScan.setImageType(profile.getProfileSetting('img_type')) self.simpleScan.setUseThreshold(profile.getProfileSettingBool('use_cr_threshold')) self.simpleScan.setThresholdValue(profile.getProfileSettingInteger('cr_threshold_value')) self.simpleScan.setColor(struct.unpack('BBB',profile.getProfileSetting('point_cloud_color').decode('hex'))) self.textureScan.setFastScan(profile.getProfileSettingBool('fast_scan')) self.textureScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning')) self.textureScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning')) self.textureScan.setImageType(profile.getProfileSetting('img_type')) self.textureScan.setUseOpen(profile.getProfileSettingBool('use_open')) self.textureScan.setOpenValue(profile.getProfileSettingInteger('open_value')) self.textureScan.setUseThreshold(profile.getProfileSettingBool('use_threshold')) self.textureScan.setThresholdValue(profile.getProfileSettingInteger('threshold_value'))
def __init__(self, parent): super(PreferencesDialog, self).__init__(None, title=_("Preferences")) self.main = parent #-- Graphic elements self.conParamsStaticText = wx.StaticText( self, label=_("Connection Parameters"), style=wx.ALIGN_CENTRE) self.serialNameLabel = wx.StaticText(self, label=_("Serial Name")) self.serialNames = self.main.serialList() self.serialNameCombo = wx.ComboBox(self, choices=self.serialNames, size=(170, -1)) self.baudRateLabel = wx.StaticText(self, label=_("Baud Rate")) self.baudRates = self.main.baudRateList() self.baudRateCombo = wx.ComboBox(self, choices=self.baudRates, size=(172, -1), style=wx.CB_READONLY) self.cameraIdLabel = wx.StaticText(self, label=_("Camera Id")) self.cameraIdNames = self.main.videoList() self.cameraIdCombo = wx.ComboBox(self, choices=self.cameraIdNames, size=(167, -1), style=wx.CB_READONLY) self.firmwareStaticText = wx.StaticText(self, label=_("Burn Firmware"), style=wx.ALIGN_CENTRE) self.boardLabel = wx.StaticText(self, label=_("AVR Board")) self.boards = profile.getProfileSettingObject('board').getType() board = profile.getProfileSetting('board') self.boardsCombo = wx.ComboBox(self, choices=self.boards, value=board, size=(168, -1), style=wx.CB_READONLY) self.hexLabel = wx.StaticText(self, label=_("Binary file")) self.hexCombo = wx.ComboBox( self, choices=[_("Default"), _("External file...")], value=_("Default"), size=(172, -1), style=wx.CB_READONLY) self.clearCheckBox = wx.CheckBox(self, label=_("Clear EEPROM")) self.uploadFirmwareButton = wx.Button(self, label=_("Upload Firmware")) self.gauge = wx.Gauge(self, range=100, size=(180, -1)) self.gauge.Hide() self.languageLabel = wx.StaticText(self, label=_("Language")) self.languages = [row[1] for row in resources.getLanguageOptions()] self.languageCombo = wx.ComboBox( self, choices=self.languages, value=profile.getPreference('language'), size=(175, -1), style=wx.CB_READONLY) invert = profile.getProfileSettingBool('invert_motor') self.invertMotorCheckBox = wx.CheckBox( self, label=_("Invert the motor direction")) self.invertMotorCheckBox.SetValue(invert) self.okButton = wx.Button(self, label=_("Ok")) #-- Events self.serialNameCombo.Bind(wx.EVT_TEXT, self.onSerialNameComboChanged) self.serialNameCombo.Bind(wx.EVT_COMBOBOX, self.onSerialNameComboChanged) self.baudRateCombo.Bind(wx.EVT_COMBOBOX, self.onBaudRateComboChanged) self.cameraIdCombo.Bind(wx.EVT_COMBOBOX, self.onCameraIdComboChanged) self.boardsCombo.Bind(wx.EVT_COMBOBOX, self.onBoardsComboChanged) self.hexCombo.Bind(wx.EVT_COMBOBOX, self.onHexComboChanged) self.uploadFirmwareButton.Bind(wx.EVT_BUTTON, self.onUploadFirmware) self.languageCombo.Bind(wx.EVT_COMBOBOX, self.onLanguageComboChanged) self.invertMotorCheckBox.Bind(wx.EVT_CHECKBOX, self.onInvertMotor) self.okButton.Bind(wx.EVT_BUTTON, self.onClose) self.Bind(wx.EVT_CLOSE, self.onClose) #-- Fill data currentSerial = profile.getProfileSetting('serial_name') if len(self.serialNames) > 0: if currentSerial not in self.serialNames: self.serialNameCombo.SetValue(self.serialNames[0]) else: self.serialNameCombo.SetValue(currentSerial) currentBaudRate = profile.getProfileSetting('baud_rate') self.baudRateCombo.SetValue(currentBaudRate) currentVideoId = profile.getProfileSetting('camera_id') if len(self.cameraIdNames) > 0: if currentVideoId not in self.cameraIdNames: self.cameraIdCombo.SetValue(self.cameraIdNames[0]) else: self.cameraIdCombo.SetValue(currentVideoId) #-- Call Events self.onSerialNameComboChanged(None) self.onCameraIdComboChanged(None) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.conParamsStaticText, 0, wx.ALL, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.serialNameLabel, 0, wx.ALL ^ wx.RIGHT, 10) hbox.Add(self.serialNameCombo, 0, wx.ALL, 5) vbox.Add(hbox) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.baudRateLabel, 0, wx.ALL, 10) hbox.Add(self.baudRateCombo, 0, wx.ALL, 5) vbox.Add(hbox) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.cameraIdLabel, 0, wx.ALL, 10) hbox.Add(self.cameraIdCombo, 0, wx.ALL, 5) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.ALL, 5) vbox.Add(self.firmwareStaticText, 0, wx.ALL, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.boardLabel, 0, wx.ALL, 10) hbox.Add(self.boardsCombo, 0, wx.ALL, 5) vbox.Add(hbox) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.hexLabel, 0, wx.ALL, 10) hbox.Add(self.hexCombo, 0, wx.ALL, 5) vbox.Add(hbox) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.uploadFirmwareButton, 0, wx.ALL, 10) hbox.Add(self.clearCheckBox, 0, wx.ALL ^ wx.LEFT, 15) vbox.Add(hbox) vbox.Add(self.gauge, 0, wx.EXPAND | wx.ALL ^ wx.TOP, 10) vbox.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.ALL ^ wx.TOP, 5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.languageLabel, 0, wx.ALL, 10) hbox.Add(self.languageCombo, 0, wx.ALL, 5) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.ALL, 5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.invertMotorCheckBox, 0, wx.ALL, 15) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.ALL, 5) vbox.Add(self.okButton, 0, wx.ALL | wx.EXPAND, 10) self.hexPath = None self.SetSizer(vbox) self.Centre() self.Layout() self.Fit()
def load(self): #-- Toolbar Configuration self.playTool = self.toolbar.AddLabelTool(wx.NewId(), _("Play"), wx.Bitmap(resources.getPathForImage("play.png")), shortHelp=_("Play")) self.stopTool = self.toolbar.AddLabelTool(wx.NewId(), _("Stop"), wx.Bitmap(resources.getPathForImage("stop.png")), shortHelp=_("Stop")) self.pauseTool = self.toolbar.AddLabelTool(wx.NewId(), _("Pause"), wx.Bitmap(resources.getPathForImage("pause.png")), shortHelp=_("Pause")) self.toolbar.Realize() #-- Disable Toolbar Items self.enableLabelTool(self.playTool , False) self.enableLabelTool(self.stopTool , False) self.enableLabelTool(self.pauseTool , False) #-- Bind Toolbar Items self.Bind(wx.EVT_TOOL, self.onPlayToolClicked , self.playTool) self.Bind(wx.EVT_TOOL, self.onStopToolClicked , self.stopTool) self.Bind(wx.EVT_TOOL, self.onPauseToolClicked , self.pauseTool) self.scrollPanel = wx.lib.scrolledpanel.ScrolledPanel(self._panel, size=(290,-1)) self.scrollPanel.SetupScrolling(scroll_x=False, scrollIntoView=False) self.scrollPanel.SetAutoLayout(1) self.controls = ExpandableControl(self.scrollPanel) self.controls.addPanel('scan_parameters', ScanParameters(self.controls)) self.controls.addPanel('rotative_platform', RotativePlatform(self.controls)) self.controls.addPanel('image_acquisition', ImageAcquisition(self.controls)) self.controls.addPanel('image_segmentation', ImageSegmentation(self.controls)) self.controls.addPanel('point_cloud_generation', PointCloudGeneration(self.controls)) self.splitterWindow = wx.SplitterWindow(self._panel) self.videoView = VideoView(self.splitterWindow, self.getFrame, 10) self.videoView.SetBackgroundColour(wx.BLACK) self.scenePanel = wx.Panel(self.splitterWindow) self.sceneView = SceneView(self.scenePanel) self.gauge = wx.Gauge(self.scenePanel, size=(-1, 30)) self.gauge.Hide() vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.sceneView, 1, wx.ALL|wx.EXPAND, 0) vbox.Add(self.gauge, 0, wx.ALL|wx.EXPAND, 0) self.scenePanel.SetSizer(vbox) self.splitterWindow.SplitVertically(self.videoView, self.scenePanel) self.splitterWindow.SetMinimumPaneSize(200) #-- Layout vsbox = wx.BoxSizer(wx.VERTICAL) vsbox.Add(self.controls, 0, wx.ALL|wx.EXPAND, 0) self.scrollPanel.SetSizer(vsbox) vsbox.Fit(self.scrollPanel) self.addToPanel(self.scrollPanel, 0) self.addToPanel(self.splitterWindow, 1) #- Video View Selector _choices = [] choices = profile.getProfileSettingObject('img_type').getType() for i in choices: _choices.append(_(i)) self.videoViewsDict = dict(zip(_choices, choices)) self.buttonShowVideoViews = wx.BitmapButton(self.videoView, wx.NewId(), wx.Bitmap(resources.getPathForImage("views.png"), wx.BITMAP_TYPE_ANY), (10,10)) self.comboVideoViews = wx.ComboBox(self.videoView, value=_(profile.getProfileSetting('img_type')), choices=_choices, style=wx.CB_READONLY, pos=(60,10)) self.buttonShowVideoViews.Hide() self.comboVideoViews.Hide() self.buttonShowVideoViews.Bind(wx.EVT_BUTTON, self.onShowVideoViews) self.comboVideoViews.Bind(wx.EVT_COMBOBOX, self.onComboBoVideoViewsSelect) self.updateCallbacks() self.Layout()
def __init__(self, parent, buttonPrevCallback=None, buttonNextCallback=None): WizardPage.__init__(self, parent, title=_("Scanning"), buttonPrevCallback=buttonPrevCallback, buttonNextCallback=buttonNextCallback) self.driver = Driver.Instance() self.pcg = PointCloudGenerator.Instance() value = abs(float(profile.getProfileSetting('step_degrees_scanning'))) if value > 1.35: value = _("Low") elif value > 0.625: value = _("Medium") else: value = _("High") self.resolutionLabel = wx.StaticText(self.panel, label=_("Resolution")) self.resolutionComboBox = wx.ComboBox( self.panel, wx.ID_ANY, value=value, choices=[_("High"), _("Medium"), _("Low")], style=wx.CB_READONLY) self.laserLabel = wx.StaticText(self.panel, label=_("Laser")) use_laser = profile.getProfileSettingObject('use_laser').getType() self.laserComboBox = wx.ComboBox( self.panel, wx.ID_ANY, value=profile.getProfileSetting('use_laser'), choices=[_(use_laser[0]), _(use_laser[1]), _(use_laser[2])], style=wx.CB_READONLY) self.scanTypeLabel = wx.StaticText(self.panel, label=_("Scan Type")) scan_type = profile.getProfileSettingObject('scan_type').getType() self.scanTypeComboBox = wx.ComboBox( self.panel, wx.ID_ANY, value=profile.getProfileSetting('scan_type'), choices=[_(scan_type[0]), _(scan_type[1])], style=wx.CB_READONLY) self.skipButton.Hide() #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.resolutionLabel, 0, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 18) hbox.Add(self.resolutionComboBox, 1, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 12) vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.laserLabel, 0, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 18) hbox.Add(self.laserComboBox, 1, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 12) vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.scanTypeLabel, 0, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 18) hbox.Add(self.scanTypeComboBox, 1, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 12) vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 5) self.panel.SetSizer(vbox) self.Layout() self.resolutionComboBox.Bind(wx.EVT_COMBOBOX, self.onResolutionComboBoxChanged) self.laserComboBox.Bind(wx.EVT_COMBOBOX, self.onLaserComboBoxChanged) self.scanTypeComboBox.Bind(wx.EVT_COMBOBOX, self.onScanTypeComboBoxChanged) self.Bind(wx.EVT_SHOW, self.onShow) self.videoView.setMilliseconds(20) self.videoView.setCallback(self.getFrame)
def __init__(self): super(MainWindow, self).__init__(None, title=_("Horus " + version.getVersion()), size=self.size) self.SetMinSize((600, 450)) ###-- Initialize Engine self.driver = Driver.Instance() self.simpleScan = scan.SimpleScan.Instance() self.textureScan = scan.TextureScan.Instance() self.pcg = scan.PointCloudGenerator.Instance() self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.simpleLaserTriangulation = calibration.SimpleLaserTriangulation.Instance() self.laserTriangulation = calibration.LaserTriangulation.Instance() self.platformExtrinsics = calibration.PlatformExtrinsics.Instance() #-- Serial Name initialization serialList = self.serialList() currentSerial = profile.getProfileSetting('serial_name') if len(serialList) > 0: if currentSerial not in serialList: profile.putProfileSetting('serial_name', serialList[0]) #-- Video Id initialization videoList = self.videoList() currentVideoId = profile.getProfileSetting('camera_id') if len(videoList) > 0: if currentVideoId not in videoList: profile.putProfileSetting('camera_id', videoList[0]) self.lastFiles = eval(profile.getPreference('last_files')) print ">>> Horus " + version.getVersion() + " <<<" ###-- Initialize GUI ##-- Set Icon icon = wx.Icon(resources.getPathForImage("horus.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(icon) ##-- Status Bar #self.CreateStatusBar() ##-- Menu Bar self.menuBar = wx.MenuBar() #-- Menu File self.menuFile = wx.Menu() self.menuLaunchWizard = self.menuFile.Append(wx.NewId(), _("Launch Wizard")) self.menuFile.AppendSeparator() self.menuLoadModel = self.menuFile.Append(wx.NewId(), _("Load Model")) self.menuSaveModel = self.menuFile.Append(wx.NewId(), _("Save Model")) self.menuClearModel = self.menuFile.Append(wx.NewId(), _("Clear Model")) self.menuFile.AppendSeparator() self.menuOpenProfile = self.menuFile.Append(wx.NewId(), _("Open Profile"), _("Opens Profile .ini")) self.menuSaveProfile = self.menuFile.Append(wx.NewId(), _("Save Profile")) self.menuResetProfile = self.menuFile.Append(wx.NewId(), _("Reset Profile")) self.menuFile.AppendSeparator() self.menuExit = self.menuFile.Append(wx.ID_EXIT, _("Exit")) self.menuBar.Append(self.menuFile, _("File")) #-- Menu Edit self.menuEdit = wx.Menu() # self.menuBasicMode = self.menuEdit.AppendRadioItem(wx.NewId(), _("Basic Mode")) # self.menuAdvancedMode = self.menuEdit.AppendRadioItem(wx.NewId(), _("Advanced Mode")) # self.menuEdit.AppendSeparator() self.menuPreferences = self.menuEdit.Append(wx.NewId(), _("Preferences")) self.menuMachineSettings = self.menuEdit.Append(wx.NewId(), _("Machine Settings")) self.menuBar.Append(self.menuEdit, _("Edit")) #-- Menu View self.menuView = wx.Menu() self.menuControl = wx.Menu() self.menuControlPanel = self.menuControl.AppendCheckItem(wx.NewId(), _("Panel")) self.menuControlVideo = self.menuControl.AppendCheckItem(wx.NewId(), _("Video")) self.menuView.AppendMenu(wx.NewId(), _("Control"), self.menuControl) self.menuCalibration = wx.Menu() self.menuCalibrationPanel = self.menuCalibration.AppendCheckItem(wx.NewId(), _("Panel")) self.menuCalibrationVideo = self.menuCalibration.AppendCheckItem(wx.NewId(), _("Video")) self.menuView.AppendMenu(wx.NewId(), _("Calibration"), self.menuCalibration) self.menuScanning = wx.Menu() self.menuScanningPanel = self.menuScanning.AppendCheckItem(wx.NewId(), _("Panel")) self.menuScanningVideo = self.menuScanning.AppendCheckItem(wx.NewId(), _("Video")) self.menuScanningScene = self.menuScanning.AppendCheckItem(wx.NewId(), _("Scene")) self.menuView.AppendMenu(wx.NewId(), _("Scanning"), self.menuScanning) self.menuBar.Append(self.menuView, _("View")) #-- Menu Help self.menuHelp = wx.Menu() self.menuWelcome = self.menuHelp.Append(wx.ID_ANY, _("Welcome")) if profile.getPreferenceBool('check_for_updates'): self.menuUpdates = self.menuHelp.Append(wx.ID_ANY, _("Updates")) self.menuWiki = self.menuHelp.Append(wx.ID_ANY, _("Wiki")) self.menuSources = self.menuHelp.Append(wx.ID_ANY, _("Sources")) self.menuIssues = self.menuHelp.Append(wx.ID_ANY, _("Issues")) self.menuForum = self.menuHelp.Append(wx.ID_ANY, _("Forum")) self.menuAbout = self.menuHelp.Append(wx.ID_ABOUT, _("About")) self.menuBar.Append(self.menuHelp, _("Help")) self.SetMenuBar(self.menuBar) ##-- Create Workbenchs self.controlWorkbench = ControlWorkbench(self) self.scanningWorkbench = ScanningWorkbench(self) self.calibrationWorkbench = CalibrationWorkbench(self) _choices = [] choices = profile.getProfileSettingObject('workbench').getType() for i in choices: _choices.append(_(i)) self.workbenchDict = dict(zip(_choices, choices)) for workbench in [self.controlWorkbench, self.calibrationWorkbench, self.scanningWorkbench]: workbench.combo.Clear() for i in choices: workbench.combo.Append(_(i)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.controlWorkbench, 1, wx.ALL|wx.EXPAND) sizer.Add(self.calibrationWorkbench, 1, wx.ALL|wx.EXPAND) sizer.Add(self.scanningWorkbench, 1, wx.ALL|wx.EXPAND) self.SetSizer(sizer) ##-- Events self.Bind(wx.EVT_MENU, self.onLaunchWizard, self.menuLaunchWizard) self.Bind(wx.EVT_MENU, self.onLoadModel, self.menuLoadModel) self.Bind(wx.EVT_MENU, self.onSaveModel, self.menuSaveModel) self.Bind(wx.EVT_MENU, self.onClearModel, self.menuClearModel) self.Bind(wx.EVT_MENU, self.onOpenProfile, self.menuOpenProfile) self.Bind(wx.EVT_MENU, self.onSaveProfile, self.menuSaveProfile) self.Bind(wx.EVT_MENU, self.onResetProfile, self.menuResetProfile) self.Bind(wx.EVT_MENU, self.onExit, self.menuExit) # self.Bind(wx.EVT_MENU, self.onModeChanged, self.menuBasicMode) # self.Bind(wx.EVT_MENU, self.onModeChanged, self.menuAdvancedMode) self.Bind(wx.EVT_MENU, self.onPreferences, self.menuPreferences) self.Bind(wx.EVT_MENU, self.onMachineSettings, self.menuMachineSettings) self.Bind(wx.EVT_MENU, self.onControlPanelClicked, self.menuControlPanel) self.Bind(wx.EVT_MENU, self.onControlVideoClicked, self.menuControlVideo) self.Bind(wx.EVT_MENU, self.onCalibrationPanelClicked, self.menuCalibrationPanel) self.Bind(wx.EVT_MENU, self.onCalibrationVideoClicked, self.menuCalibrationVideo) self.Bind(wx.EVT_MENU, self.onScanningPanelClicked, self.menuScanningPanel) self.Bind(wx.EVT_MENU, self.onScanningVideoSceneClicked, self.menuScanningVideo) self.Bind(wx.EVT_MENU, self.onScanningVideoSceneClicked, self.menuScanningScene) self.Bind(wx.EVT_MENU, self.onAbout, self.menuAbout) self.Bind(wx.EVT_MENU, self.onWelcome, self.menuWelcome) if profile.getPreferenceBool('check_for_updates'): self.Bind(wx.EVT_MENU, self.onUpdates, self.menuUpdates) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/bq/horus/wiki'), self.menuWiki) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/bq/horus'), self.menuSources) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/bq/horus/issues'), self.menuIssues) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://groups.google.com/forum/?hl=es#!forum/ciclop-3d-scanner'), self.menuForum) self.Bind(wx.EVT_COMBOBOX, self.onComboBoxWorkbenchSelected, self.controlWorkbench.combo) self.Bind(wx.EVT_COMBOBOX, self.onComboBoxWorkbenchSelected, self.calibrationWorkbench.combo) self.Bind(wx.EVT_COMBOBOX, self.onComboBoxWorkbenchSelected, self.scanningWorkbench.combo) self.Bind(wx.EVT_CLOSE, self.onClose) self.updateProfileToAllControls() x, y, w, h = wx.Display(0).GetGeometry() ws, hs = self.size self.SetPosition((x+(w-ws)/2., y+(h-hs)/2.))
def __init__(self, parent): super(SettingsWindow, self).__init__(parent, title=_('Settings'), size=(420, -1), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER) self.driver = Driver.Instance() self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.simpleLaserTriangulation = calibration.SimpleLaserTriangulation.Instance( ) self.laserTriangulation = calibration.LaserTriangulation.Instance() self.platformExtrinsics = calibration.PlatformExtrinsics.Instance() #-- Elements _choices = [] choices = profile.getProfileSettingObject('luminosity').getType() for i in choices: _choices.append(_(i)) self.initLuminosity = profile.getProfileSetting('luminosity') self.luminosityDict = dict(zip(_choices, choices)) self.luminosityText = wx.StaticText(self, label=_('Luminosity')) self.luminosityText.SetToolTip( wx.ToolTip( _('Change the luminosity until colored lines appear over the chess pattern in the video' ))) self.luminosityComboBox = wx.ComboBox(self, wx.ID_ANY, value=_(self.initLuminosity), choices=_choices, style=wx.CB_READONLY) invert = profile.getProfileSettingBool('invert_motor') self.invertMotorCheckBox = wx.CheckBox( self, label=_("Invert the motor direction")) self.invertMotorCheckBox.SetValue(invert) tooltip = _( "Minimum distance between the origin of the pattern (bottom-left corner) and the pattern's base surface" ) self.image = wx.Image( resources.getPathForImage("pattern-distance.jpg"), wx.BITMAP_TYPE_ANY) self.patternDistance = float( profile.getProfileSetting('pattern_distance')) self.patternImage = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(self.image)) self.patternImage.SetToolTip(wx.ToolTip(tooltip)) self.patternLabel = wx.StaticText(self, label=_('Pattern distance (mm)')) self.patternLabel.SetToolTip(wx.ToolTip(tooltip)) self.patternTextbox = wx.TextCtrl( self, value=str(profile.getProfileSettingFloat('pattern_distance'))) self.okButton = wx.Button(self, label=_('OK')) self.cancelButton = wx.Button(self, label=_('Cancel')) #-- Events self.luminosityComboBox.Bind(wx.EVT_COMBOBOX, self.onLuminosityComboBoxChanged) self.invertMotorCheckBox.Bind(wx.EVT_CHECKBOX, self.onInvertMotor) self.patternTextbox.Bind(wx.EVT_TEXT, self.onTextBoxChanged) self.cancelButton.Bind(wx.EVT_BUTTON, self.onClose) self.okButton.Bind(wx.EVT_BUTTON, self.onOk) self.Bind(wx.EVT_CLOSE, self.onClose) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.luminosityText, 0, wx.ALL, 7) hbox.Add(self.luminosityComboBox, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 7) vbox.Add(wx.StaticLine(self), 0, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.invertMotorCheckBox, 0, wx.ALL, 10) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.ALL ^ wx.BOTTOM ^ wx.TOP | wx.EXPAND, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.patternLabel, 0, wx.ALL, 7) hbox.Add(self.patternTextbox, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL ^ wx.BOTTOM | wx.EXPAND, 10) vbox.Add(self.patternImage, 0, wx.ALL | wx.CENTER, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.cancelButton, 1, wx.ALL, 3) hbox.Add(self.okButton, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 10) self.SetSizer(vbox) self.Center() self.Fit() self.ShowModal()
def __init__(self, parent, buttonPrevCallback=None, buttonNextCallback=None): WizardPage.__init__(self, parent, title=_("Scanning"), buttonPrevCallback=buttonPrevCallback, buttonNextCallback=buttonNextCallback) self.driver = Driver.Instance() self.pcg = PointCloudGenerator.Instance() value = abs(float(profile.getProfileSetting('step_degrees_scanning'))) if value > 1.35: value = _("Low") elif value > 0.625: value = _("Medium") else: value = _("High") self.resolutionLabel = wx.StaticText(self.panel, label=_("Resolution")) self.resolutionComboBox = wx.ComboBox(self.panel, wx.ID_ANY, value=value, choices=[_("High"), _("Medium"), _("Low")], style=wx.CB_READONLY) _choices = [] choices = profile.getProfileSettingObject('use_laser').getType() for i in choices: _choices.append(_(i)) self.laserDict = dict(zip(_choices, choices)) self.laserLabel = wx.StaticText(self.panel, label=_("Laser")) useLaser = profile.getProfileSettingObject('use_laser').getType() self.laserComboBox = wx.ComboBox(self.panel, wx.ID_ANY, value=_(profile.getProfileSetting('use_laser')), choices=_choices, style=wx.CB_READONLY) _choices = [] choices = profile.getProfileSettingObject('scan_type').getType() for i in choices: _choices.append(_(i)) self.scanTypeDict = dict(zip(_choices, choices)) self.scanTypeLabel = wx.StaticText(self.panel, label=_('Scan')) scanType = profile.getProfileSettingObject('scan_type').getType() self.scanTypeComboBox = wx.ComboBox(self.panel, wx.ID_ANY, value=_(profile.getProfileSetting('scan_type')), choices=_choices, style=wx.CB_READONLY) self.skipButton.Hide() #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.resolutionLabel, 0, wx.ALL^wx.BOTTOM|wx.EXPAND, 18) hbox.Add(self.resolutionComboBox, 1, wx.ALL^wx.BOTTOM|wx.EXPAND, 12) vbox.Add(hbox, 0, wx.ALL|wx.EXPAND, 5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.laserLabel, 0, wx.ALL^wx.BOTTOM|wx.EXPAND, 18) hbox.Add(self.laserComboBox, 1, wx.ALL^wx.BOTTOM|wx.EXPAND, 12) vbox.Add(hbox, 0, wx.ALL|wx.EXPAND, 5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.scanTypeLabel, 0, wx.ALL^wx.BOTTOM|wx.EXPAND, 18) hbox.Add(self.scanTypeComboBox, 1, wx.ALL^wx.BOTTOM|wx.EXPAND, 12) vbox.Add(hbox, 0, wx.ALL|wx.EXPAND, 5) self.panel.SetSizer(vbox) self.Layout() self.resolutionComboBox.Bind(wx.EVT_COMBOBOX, self.onResolutionComboBoxChanged) self.laserComboBox.Bind(wx.EVT_COMBOBOX, self.onLaserComboBoxChanged) self.scanTypeComboBox.Bind(wx.EVT_COMBOBOX, self.onScanTypeComboBoxChanged) self.Bind(wx.EVT_SHOW, self.onShow) self.videoView.setMilliseconds(20) self.videoView.setCallback(self.getFrame)
def __init__(self): super(MainWindow, self).__init__(None, title=_("Horus " + VERSION + " - Beta"), size=self.size) self.SetMinSize((600, 450)) ###-- Initialize Engine self.driver = Driver.Instance() self.simpleScan = scan.SimpleScan.Instance() self.textureScan = scan.TextureScan.Instance() self.pcg = scan.PointCloudGenerator.Instance() self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.simpleLaserTriangulation = calibration.SimpleLaserTriangulation.Instance() self.laserTriangulation = calibration.LaserTriangulation.Instance() self.platformExtrinsics = calibration.PlatformExtrinsics.Instance() #-- Serial Name initialization serialList = self.serialList() currentSerial = profile.getProfileSetting('serial_name') if len(serialList) > 0: if currentSerial not in serialList: profile.putProfileSetting('serial_name', serialList[0]) #-- Video Id initialization videoList = self.videoList() currentVideoId = profile.getProfileSetting('camera_id') if len(videoList) > 0: if currentVideoId not in videoList: profile.putProfileSetting('camera_id', videoList[0]) self.lastFiles = eval(profile.getPreference('last_files')) print ">>> Horus " + VERSION + " <<<" ###-- Initialize GUI ##-- Set Icon icon = wx.Icon(resources.getPathForImage("horus.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(icon) ##-- Status Bar #self.CreateStatusBar() ##-- Menu Bar self.menuBar = wx.MenuBar() #-- Menu File self.menuFile = wx.Menu() self.menuLaunchWizard = self.menuFile.Append(wx.NewId(), _("Launch Wizard")) self.menuFile.AppendSeparator() self.menuLoadModel = self.menuFile.Append(wx.NewId(), _("Load Model")) self.menuSaveModel = self.menuFile.Append(wx.NewId(), _("Save Model")) self.menuClearModel = self.menuFile.Append(wx.NewId(), _("Clear Model")) self.menuFile.AppendSeparator() self.menuOpenProfile = self.menuFile.Append(wx.NewId(), _("Open Profile"), _("Opens Profile .ini")) self.menuSaveProfile = self.menuFile.Append(wx.NewId(), _("Save Profile")) self.menuResetProfile = self.menuFile.Append(wx.NewId(), _("Reset Profile")) self.menuFile.AppendSeparator() self.menuExit = self.menuFile.Append(wx.ID_EXIT, _("Exit")) self.menuBar.Append(self.menuFile, _("File")) #-- Menu Edit self.menuEdit = wx.Menu() # self.menuBasicMode = self.menuEdit.AppendRadioItem(wx.NewId(), _("Basic Mode")) # self.menuAdvancedMode = self.menuEdit.AppendRadioItem(wx.NewId(), _("Advanced Mode")) # self.menuEdit.AppendSeparator() self.menuPreferences = self.menuEdit.Append(wx.NewId(), _("Preferences")) self.menuBar.Append(self.menuEdit, _("Edit")) #-- Menu View self.menuView = wx.Menu() self.menuControl = wx.Menu() self.menuControlPanel = self.menuControl.AppendCheckItem(wx.NewId(), _("Panel")) self.menuControlVideo = self.menuControl.AppendCheckItem(wx.NewId(), _("Video")) self.menuView.AppendMenu(wx.NewId(), _("Control"), self.menuControl) self.menuCalibration = wx.Menu() self.menuCalibrationPanel = self.menuCalibration.AppendCheckItem(wx.NewId(), _("Panel")) self.menuCalibrationVideo = self.menuCalibration.AppendCheckItem(wx.NewId(), _("Video")) self.menuView.AppendMenu(wx.NewId(), _("Calibration"), self.menuCalibration) self.menuScanning = wx.Menu() self.menuScanningPanel = self.menuScanning.AppendCheckItem(wx.NewId(), _("Panel")) self.menuScanningVideo = self.menuScanning.AppendCheckItem(wx.NewId(), _("Video")) self.menuScanningScene = self.menuScanning.AppendCheckItem(wx.NewId(), _("Scene")) self.menuView.AppendMenu(wx.NewId(), _("Scanning"), self.menuScanning) self.menuBar.Append(self.menuView, _("View")) #-- Menu Help self.menuHelp = wx.Menu() self.menuWelcome = self.menuHelp.Append(wx.ID_ANY, _("Welcome")) self.menuWiki = self.menuHelp.Append(wx.ID_ANY, _("Wiki")) self.menuSources = self.menuHelp.Append(wx.ID_ANY, _("Sources")) self.menuIssues = self.menuHelp.Append(wx.ID_ANY, _("Issues")) self.menuForum = self.menuHelp.Append(wx.ID_ANY, _("Forum")) self.menuAbout = self.menuHelp.Append(wx.ID_ABOUT, _("About")) self.menuBar.Append(self.menuHelp, _("Help")) self.SetMenuBar(self.menuBar) ##-- Create Workbenchs self.controlWorkbench = ControlWorkbench(self) self.scanningWorkbench = ScanningWorkbench(self) self.calibrationWorkbench = CalibrationWorkbench(self) _choices = [] choices = profile.getProfileSettingObject('workbench').getType() for i in choices: _choices.append(_(i)) self.workbenchDict = dict(zip(_choices, choices)) for workbench in [self.controlWorkbench, self.calibrationWorkbench, self.scanningWorkbench]: workbench.combo.Clear() for i in choices: workbench.combo.Append(_(i)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.controlWorkbench, 1, wx.ALL|wx.EXPAND) sizer.Add(self.calibrationWorkbench, 1, wx.ALL|wx.EXPAND) sizer.Add(self.scanningWorkbench, 1, wx.ALL|wx.EXPAND) self.SetSizer(sizer) ##-- Events self.Bind(wx.EVT_MENU, self.onLaunchWizard, self.menuLaunchWizard) self.Bind(wx.EVT_MENU, self.onLoadModel, self.menuLoadModel) self.Bind(wx.EVT_MENU, self.onSaveModel, self.menuSaveModel) self.Bind(wx.EVT_MENU, self.onClearModel, self.menuClearModel) self.Bind(wx.EVT_MENU, self.onOpenProfile, self.menuOpenProfile) self.Bind(wx.EVT_MENU, self.onSaveProfile, self.menuSaveProfile) self.Bind(wx.EVT_MENU, self.onResetProfile, self.menuResetProfile) self.Bind(wx.EVT_MENU, self.onExit, self.menuExit) # self.Bind(wx.EVT_MENU, self.onModeChanged, self.menuBasicMode) # self.Bind(wx.EVT_MENU, self.onModeChanged, self.menuAdvancedMode) self.Bind(wx.EVT_MENU, self.onPreferences, self.menuPreferences) self.Bind(wx.EVT_MENU, self.onControlPanelClicked, self.menuControlPanel) self.Bind(wx.EVT_MENU, self.onControlVideoClicked, self.menuControlVideo) self.Bind(wx.EVT_MENU, self.onCalibrationPanelClicked, self.menuCalibrationPanel) self.Bind(wx.EVT_MENU, self.onCalibrationVideoClicked, self.menuCalibrationVideo) self.Bind(wx.EVT_MENU, self.onScanningPanelClicked, self.menuScanningPanel) self.Bind(wx.EVT_MENU, self.onScanningVideoSceneClicked, self.menuScanningVideo) self.Bind(wx.EVT_MENU, self.onScanningVideoSceneClicked, self.menuScanningScene) self.Bind(wx.EVT_MENU, self.onAbout, self.menuAbout) self.Bind(wx.EVT_MENU, self.onWelcome, self.menuWelcome) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/bq/horus/wiki'), self.menuWiki) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/bq/horus'), self.menuSources) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/bq/horus/issues'), self.menuIssues) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://groups.google.com/forum/?hl=es#!forum/ciclop-3d-scanner'), self.menuForum) self.Bind(wx.EVT_COMBOBOX, self.onComboBoxWorkbenchSelected, self.controlWorkbench.combo) self.Bind(wx.EVT_COMBOBOX, self.onComboBoxWorkbenchSelected, self.calibrationWorkbench.combo) self.Bind(wx.EVT_COMBOBOX, self.onComboBoxWorkbenchSelected, self.scanningWorkbench.combo) self.Bind(wx.EVT_CLOSE, self.onClose) self.updateProfileToAllControls() x, y, w, h = wx.Display(0).GetGeometry() ws, hs = self.size self.SetPosition((x+(w-ws)/2., y+(h-hs)/2.)) #self.Center() self.Show()
def updateProfile(self): if hasattr(self,'control'): value = profile.getProfileSetting(self.name) self.update(value)
def updateDriverProfile(self): self.driver.camera.setCameraId(int(profile.getProfileSetting('camera_id')[-1:])) self.driver.board.setSerialName(profile.getProfileSetting('serial_name')) self.driver.board.setBaudRate(profile.getProfileSettingInteger('baud_rate')) self.driver.board.setInvertMotor(profile.getProfileSettingBool('invert_motor'))
def __init__(self): super(MainWindow, self).__init__(None, title=_("Horus " + VERSION + " - Beta"), size=self.size) self.SetMinSize((600, 450)) ###-- Initialize Engine self.driver = Driver.Instance() self.simpleScan = scan.SimpleScan.Instance() self.textureScan = scan.TextureScan.Instance() self.pcg = scan.PointCloudGenerator.Instance() self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.simpleLaserTriangulation = calibration.SimpleLaserTriangulation.Instance( ) self.laserTriangulation = calibration.LaserTriangulation.Instance() self.platformExtrinsics = calibration.PlatformExtrinsics.Instance() #-- Serial Name initialization serialList = self.serialList() currentSerial = profile.getProfileSetting('serial_name') if len(serialList) > 0: if currentSerial not in serialList: profile.putProfileSetting('serial_name', serialList[0]) #-- Video Id initialization videoList = self.videoList() currentVideoId = profile.getProfileSetting('camera_id') if len(videoList) > 0: if currentVideoId not in videoList: profile.putProfileSetting('camera_id', videoList[0]) self.workbenchList = { 'control': _("Control workbench"), 'calibration': _("Calibration workbench"), 'scanning': _("Scanning workbench") } self.lastFiles = eval(profile.getPreference('last_files')) print ">>> Horus " + VERSION + " <<<" ###-- Initialize GUI ##-- Set Icon icon = wx.Icon(resources.getPathForImage("horus.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(icon) ##-- Status Bar #self.CreateStatusBar() ##-- Menu Bar self.menuBar = wx.MenuBar() #-- Menu File self.menuFile = wx.Menu() self.menuLaunchWizard = self.menuFile.Append(wx.NewId(), _("Launch Wizard")) self.menuFile.AppendSeparator() self.menuLoadModel = self.menuFile.Append(wx.NewId(), _("Load Model")) self.menuSaveModel = self.menuFile.Append(wx.NewId(), _("Save Model")) self.menuClearModel = self.menuFile.Append(wx.NewId(), _("Clear Model")) self.menuFile.AppendSeparator() self.menuOpenProfile = self.menuFile.Append(wx.NewId(), _("Open Profile"), _("Opens Profile .ini")) self.menuSaveProfile = self.menuFile.Append(wx.NewId(), _("Save Profile")) self.menuResetProfile = self.menuFile.Append(wx.NewId(), _("Reset Profile")) self.menuFile.AppendSeparator() menuExit = self.menuFile.Append(wx.ID_EXIT, _("Exit")) self.menuBar.Append(self.menuFile, _("File")) #-- Menu Edit self.menuEdit = wx.Menu() self.menuBasicMode = self.menuEdit.AppendRadioItem( wx.NewId(), _("Basic Mode")) self.menuAdvancedMode = self.menuEdit.AppendRadioItem( wx.NewId(), _("Advanced Mode")) self.menuEdit.AppendSeparator() self.menuPreferences = self.menuEdit.Append(wx.NewId(), _("Preferences")) self.menuBar.Append(self.menuEdit, _("Edit")) #-- Menu View menuView = wx.Menu() self.menuControl = wx.Menu() self.menuControlPanel = self.menuControl.AppendCheckItem( wx.NewId(), _("Panel")) self.menuControlVideo = self.menuControl.AppendCheckItem( wx.NewId(), _("Video")) menuView.AppendMenu(wx.NewId(), _("Control"), self.menuControl) self.menuCalibration = wx.Menu() self.menuCalibrationPanel = self.menuCalibration.AppendCheckItem( wx.NewId(), _("Panel")) self.menuCalibrationVideo = self.menuCalibration.AppendCheckItem( wx.NewId(), _("Video")) menuView.AppendMenu(wx.NewId(), _("Calibration"), self.menuCalibration) self.menuScanning = wx.Menu() self.menuScanningPanel = self.menuScanning.AppendCheckItem( wx.NewId(), _("Panel")) self.menuScanningVideo = self.menuScanning.AppendCheckItem( wx.NewId(), _("Video")) self.menuScanningScene = self.menuScanning.AppendCheckItem( wx.NewId(), _("Scene")) menuView.AppendMenu(wx.NewId(), _("Scanning"), self.menuScanning) self.menuBar.Append(menuView, _("View")) #-- Menu Help menuHelp = wx.Menu() menuAbout = menuHelp.Append(wx.ID_ABOUT, _("About")) menuWelcome = menuHelp.Append(wx.ID_ANY, _("Welcome")) self.menuBar.Append(menuHelp, _("Help")) self.SetMenuBar(self.menuBar) ##-- Create Workbenchs self.controlWorkbench = ControlWorkbench(self) self.scanningWorkbench = ScanningWorkbench(self) self.calibrationWorkbench = CalibrationWorkbench(self) for workbench in [ self.controlWorkbench, self.calibrationWorkbench, self.scanningWorkbench ]: workbench.combo.Clear() workbench.combo.Append(self.workbenchList['control']) workbench.combo.Append(self.workbenchList['calibration']) workbench.combo.Append(self.workbenchList['scanning']) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.controlWorkbench, 1, wx.ALL | wx.EXPAND) sizer.Add(self.calibrationWorkbench, 1, wx.ALL | wx.EXPAND) sizer.Add(self.scanningWorkbench, 1, wx.ALL | wx.EXPAND) self.SetSizer(sizer) ##-- Events self.Bind(wx.EVT_MENU, self.onLaunchWizard, self.menuLaunchWizard) self.Bind(wx.EVT_MENU, self.onLoadModel, self.menuLoadModel) self.Bind(wx.EVT_MENU, self.onSaveModel, self.menuSaveModel) self.Bind(wx.EVT_MENU, self.onClearModel, self.menuClearModel) self.Bind(wx.EVT_MENU, self.onOpenProfile, self.menuOpenProfile) self.Bind(wx.EVT_MENU, self.onSaveProfile, self.menuSaveProfile) self.Bind(wx.EVT_MENU, self.onResetProfile, self.menuResetProfile) self.Bind(wx.EVT_MENU, self.onExit, menuExit) self.Bind(wx.EVT_MENU, self.onModeChanged, self.menuBasicMode) self.Bind(wx.EVT_MENU, self.onModeChanged, self.menuAdvancedMode) self.Bind(wx.EVT_MENU, self.onPreferences, self.menuPreferences) self.Bind(wx.EVT_MENU, self.onControlPanelClicked, self.menuControlPanel) self.Bind(wx.EVT_MENU, self.onControlVideoClicked, self.menuControlVideo) self.Bind(wx.EVT_MENU, self.onCalibrationPanelClicked, self.menuCalibrationPanel) self.Bind(wx.EVT_MENU, self.onCalibrationVideoClicked, self.menuCalibrationVideo) self.Bind(wx.EVT_MENU, self.onScanningPanelClicked, self.menuScanningPanel) self.Bind(wx.EVT_MENU, self.onScanningVideoSceneClicked, self.menuScanningVideo) self.Bind(wx.EVT_MENU, self.onScanningVideoSceneClicked, self.menuScanningScene) self.Bind(wx.EVT_MENU, self.onAbout, menuAbout) self.Bind(wx.EVT_MENU, self.onWelcome, menuWelcome) self.Bind(wx.EVT_COMBOBOX, self.onComboBoxWorkbenchSelected, self.controlWorkbench.combo) self.Bind(wx.EVT_COMBOBOX, self.onComboBoxWorkbenchSelected, self.calibrationWorkbench.combo) self.Bind(wx.EVT_COMBOBOX, self.onComboBoxWorkbenchSelected, self.scanningWorkbench.combo) self.Bind(wx.EVT_CLOSE, self.onClose) self.updateProfileToAllControls() x, y, w, h = wx.Display(0).GetGeometry() ws, hs = self.size self.SetPosition((x + (w - ws) / 2., y + (h - hs) / 2.)) #self.Center() self.Show()
def load(self): #-- Toolbar Configuration self.playTool = self.toolbar.AddLabelTool( wx.NewId(), _("Play"), wx.Bitmap(resources.getPathForImage("play.png")), shortHelp=_("Play")) self.stopTool = self.toolbar.AddLabelTool( wx.NewId(), _("Stop"), wx.Bitmap(resources.getPathForImage("stop.png")), shortHelp=_("Stop")) self.pauseTool = self.toolbar.AddLabelTool( wx.NewId(), _("Pause"), wx.Bitmap(resources.getPathForImage("pause.png")), shortHelp=_("Pause")) self.toolbar.Realize() #-- Disable Toolbar Items self.enableLabelTool(self.playTool, False) self.enableLabelTool(self.stopTool, False) self.enableLabelTool(self.pauseTool, False) #-- Bind Toolbar Items self.Bind(wx.EVT_TOOL, self.onPlayToolClicked, self.playTool) self.Bind(wx.EVT_TOOL, self.onStopToolClicked, self.stopTool) self.Bind(wx.EVT_TOOL, self.onPauseToolClicked, self.pauseTool) self.scrollPanel = wx.lib.scrolledpanel.ScrolledPanel(self._panel, size=(290, -1)) self.scrollPanel.SetupScrolling(scroll_x=False, scrollIntoView=False) self.scrollPanel.SetAutoLayout(1) self.controls = ExpandableControl(self.scrollPanel) self.controls.addPanel('scan_parameters', ScanParameters(self.controls)) self.controls.addPanel('rotative_platform', RotativePlatform(self.controls)) self.controls.addPanel('image_acquisition', ImageAcquisition(self.controls)) self.controls.addPanel('image_segmentation', ImageSegmentation(self.controls)) self.controls.addPanel('point_cloud_generation', PointCloudGeneration(self.controls)) self.splitterWindow = wx.SplitterWindow(self._panel) self.videoView = VideoView(self.splitterWindow, self.getFrame, 10) self.videoView.SetBackgroundColour(wx.BLACK) self.scenePanel = wx.Panel(self.splitterWindow) self.sceneView = SceneView(self.scenePanel) self.gauge = wx.Gauge(self.scenePanel, size=(-1, 30)) self.gauge.Hide() vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.sceneView, 1, wx.ALL | wx.EXPAND, 0) vbox.Add(self.gauge, 0, wx.ALL | wx.EXPAND, 0) self.scenePanel.SetSizer(vbox) self.splitterWindow.SplitVertically(self.videoView, self.scenePanel) self.splitterWindow.SetMinimumPaneSize(200) #-- Layout vsbox = wx.BoxSizer(wx.VERTICAL) vsbox.Add(self.controls, 0, wx.ALL | wx.EXPAND, 0) self.scrollPanel.SetSizer(vsbox) vsbox.Fit(self.scrollPanel) self.addToPanel(self.scrollPanel, 0) self.addToPanel(self.splitterWindow, 1) #- Video View Selector _choices = [] choices = profile.getProfileSettingObject('img_type').getType() for i in choices: _choices.append(_(i)) self.videoViewsDict = dict(zip(_choices, choices)) self.buttonShowVideoViews = wx.BitmapButton( self.videoView, wx.NewId(), wx.Bitmap(resources.getPathForImage("views.png"), wx.BITMAP_TYPE_ANY), (10, 10)) self.comboVideoViews = wx.ComboBox( self.videoView, value=_(profile.getProfileSetting('img_type')), choices=_choices, style=wx.CB_READONLY, pos=(60, 10)) self.buttonShowVideoViews.Hide() self.comboVideoViews.Hide() self.buttonShowVideoViews.Bind(wx.EVT_BUTTON, self.onShowVideoViews) self.comboVideoViews.Bind(wx.EVT_COMBOBOX, self.onComboBoVideoViewsSelect) self.updateCallbacks() self.Layout()
def __init__(self, parent): super(PreferencesDialog, self).__init__(None, title=_("Preferences")) self.main = parent #-- Graphic elements self.conParamsStaticText = wx.StaticText(self, label=_("Connection Parameters"), style=wx.ALIGN_CENTRE) self.serialNameLabel = wx.StaticText(self, label=_("Serial Name")) self.serialNames = self.main.serialList() self.serialNameCombo = wx.ComboBox(self, choices=self.serialNames, size=(170,-1)) self.baudRateLabel = wx.StaticText(self, label=_("Baud Rate")) self.baudRates = self.main.baudRateList() self.baudRateCombo = wx.ComboBox(self, choices=self.baudRates, size=(172,-1), style=wx.CB_READONLY) self.cameraIdLabel = wx.StaticText(self, label=_("Camera Id")) self.cameraIdNames = self.main.videoList() self.cameraIdCombo = wx.ComboBox(self, choices=self.cameraIdNames, size=(173,-1), style=wx.CB_READONLY) self.firmwareStaticText = wx.StaticText(self, label=_("Burn Firmware"), style=wx.ALIGN_CENTRE) self.boardLabel = wx.StaticText(self, label=_("AVR Board")) self.boards = profile.getProfileSettingObject('board').getType() board = profile.getProfileSetting('board') self.boardsCombo = wx.ComboBox(self, choices=self.boards, value=board , size=(170,-1), style=wx.CB_READONLY) self.clearCheckBox = wx.CheckBox(self, label=_("Clear EEPROM")) self.uploadFirmwareButton = wx.Button(self, label=_("Upload Firmware")) self.gauge = wx.Gauge(self, range=100, size=(180, 30)) self.gauge.Hide() self.languageLabel = wx.StaticText(self, label=_("Language")) self.languages = [row[1] for row in resources.getLanguageOptions()] self.languageCombo = wx.ComboBox(self, choices=self.languages, value=profile.getPreference('language') , size=(177,-1), style=wx.CB_READONLY) invert = profile.getProfileSettingBool('invert_motor') self.invertMotorCheckBox = wx.CheckBox(self, label=_("Invert the motor direction")) self.invertMotorCheckBox.SetValue(invert) self.okButton = wx.Button(self, label=_("Ok")) #-- Events self.serialNameCombo.Bind(wx.EVT_TEXT, self.onSerialNameTextChanged) self.baudRateCombo.Bind(wx.EVT_TEXT, self.onBaudRateTextChanged) self.cameraIdCombo.Bind(wx.EVT_TEXT, self.onCameraIdTextChanged) self.boardsCombo.Bind(wx.EVT_COMBOBOX, self.onBoardsComboChanged) self.uploadFirmwareButton.Bind(wx.EVT_BUTTON, self.onUploadFirmware) self.languageCombo.Bind(wx.EVT_COMBOBOX, self.onLanguageComboChanged) self.invertMotorCheckBox.Bind(wx.EVT_CHECKBOX, self.onInvertMotor) self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Destroy()) self.Bind(wx.EVT_CLOSE, lambda e: self.Destroy()) #-- Fill data currentSerial = profile.getProfileSetting('serial_name') if len(self.serialNames) > 0: if currentSerial not in self.serialNames: self.serialNameCombo.SetValue(self.serialNames[0]) else: self.serialNameCombo.SetValue(currentSerial) currentBaudRate = profile.getProfileSetting('baud_rate') self.baudRateCombo.SetValue(currentBaudRate) currentVideoId = profile.getProfileSetting('camera_id') if len(self.cameraIdNames) > 0: if currentVideoId not in self.cameraIdNames: self.cameraIdCombo.SetValue(self.cameraIdNames[0]) else: self.cameraIdCombo.SetValue(currentVideoId) #-- Call Events self.onSerialNameTextChanged(None) self.onCameraIdTextChanged(None) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.conParamsStaticText, 0, wx.ALL, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.serialNameLabel, 0, wx.ALL^wx.RIGHT, 10) hbox.Add(self.serialNameCombo, 0, wx.ALL, 5) vbox.Add(hbox) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.baudRateLabel, 0, wx.ALL, 10) hbox.Add(self.baudRateCombo, 0, wx.ALL, 5) vbox.Add(hbox) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.cameraIdLabel, 0, wx.ALL, 10) hbox.Add(self.cameraIdCombo, 0, wx.ALL, 5) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5) vbox.Add(self.firmwareStaticText, 0, wx.ALL, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.boardLabel, 0, wx.ALL, 10) hbox.Add(self.boardsCombo, 0, wx.ALL, 5) vbox.Add(hbox) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.uploadFirmwareButton, 0, wx.ALL, 10) hbox.Add(self.clearCheckBox, 0, wx.ALL^wx.LEFT, 15) vbox.Add(hbox) vbox.Add(self.gauge, 0, wx.EXPAND|wx.ALL^wx.TOP, 10) vbox.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL^wx.TOP, 5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.languageLabel, 0, wx.ALL, 10) hbox.Add(self.languageCombo, 0, wx.ALL, 5) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.invertMotorCheckBox, 0, wx.ALL, 15) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5) vbox.Add(self.okButton, 0, wx.ALL|wx.EXPAND, 10) self.SetSizer(vbox) self.Centre() self.Fit()
def __init__(self, parent): super(SettingsWindow, self).__init__(parent, title=_('Settings'), size=(420,-1), style=wx.DEFAULT_FRAME_STYLE^wx.RESIZE_BORDER) self.driver = Driver.Instance() self.cameraIntrinsics = calibration.CameraIntrinsics.Instance() self.simpleLaserTriangulation = calibration.SimpleLaserTriangulation.Instance() self.laserTriangulation = calibration.LaserTriangulation.Instance() self.platformExtrinsics = calibration.PlatformExtrinsics.Instance() #-- Elements _choices = [] choices = profile.getProfileSettingObject('luminosity').getType() for i in choices: _choices.append(_(i)) self.initLuminosity = profile.getProfileSetting('luminosity') self.luminosityDict = dict(zip(_choices, choices)) self.luminosityText = wx.StaticText(self, label=_('Luminosity')) self.luminosityText.SetToolTip(wx.ToolTip(_('Change the luminosity until colored lines appear over the chess pattern in the video'))) self.luminosityComboBox = wx.ComboBox(self, wx.ID_ANY, value=_(self.initLuminosity), choices=_choices, style=wx.CB_READONLY) invert = profile.getProfileSettingBool('invert_motor') self.invertMotorCheckBox = wx.CheckBox(self, label=_("Invert the motor direction")) self.invertMotorCheckBox.SetValue(invert) tooltip = _("Minimum distance between the origin of the pattern (bottom-left corner) and the pattern's base surface") self.image = wx.Image(resources.getPathForImage("pattern-distance.jpg"), wx.BITMAP_TYPE_ANY) self.patternDistance = float(profile.getProfileSetting('pattern_distance')) self.patternImage = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(self.image)) self.patternImage.SetToolTip(wx.ToolTip(tooltip)) self.patternLabel = wx.StaticText(self, label=_('Pattern distance (mm)')) self.patternLabel.SetToolTip(wx.ToolTip(tooltip)) self.patternTextbox = wx.TextCtrl(self, value = str(profile.getProfileSettingFloat('pattern_distance'))) self.okButton = wx.Button(self, label=_('OK')) self.cancelButton = wx.Button(self, label=_('Cancel')) #-- Events self.luminosityComboBox.Bind(wx.EVT_COMBOBOX, self.onLuminosityComboBoxChanged) self.invertMotorCheckBox.Bind(wx.EVT_CHECKBOX, self.onInvertMotor) self.patternTextbox.Bind(wx.EVT_TEXT, self.onTextBoxChanged) self.cancelButton.Bind(wx.EVT_BUTTON, self.onClose) self.okButton.Bind(wx.EVT_BUTTON, self.onOk) self.Bind(wx.EVT_CLOSE, self.onClose) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.luminosityText, 0, wx.ALL, 7) hbox.Add(self.luminosityComboBox, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL^wx.BOTTOM|wx.EXPAND, 7) vbox.Add(wx.StaticLine(self), 0, wx.ALL^wx.BOTTOM|wx.EXPAND, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.invertMotorCheckBox, 0, wx.ALL, 10) vbox.Add(hbox) vbox.Add(wx.StaticLine(self), 0, wx.ALL^wx.BOTTOM^wx.TOP|wx.EXPAND, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.patternLabel, 0, wx.ALL, 7) hbox.Add(self.patternTextbox, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL^wx.BOTTOM|wx.EXPAND, 10) vbox.Add(self.patternImage, 0, wx.ALL|wx.CENTER, 10) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.cancelButton, 1, wx.ALL, 3) hbox.Add(self.okButton, 1, wx.ALL, 3) vbox.Add(hbox, 0, wx.ALL|wx.EXPAND, 10) self.SetSizer(vbox) self.Center() self.Fit() self.ShowModal()
def setResolution(self, value): if value != self.last_resolution: ResolutionWindow(self) self.driver.camera.setResolution(int(value.split('x')[0]), int(value.split('x')[1])) self.last_resolution = profile.getProfileSetting('resolution_calibration')