def afterLaserCalibration(self, response): self.phase = 'platformCalibration' ret, result = response if ret: profile.putProfileSetting('distance_left', result[0][0]) profile.putProfileSettingNumpy('normal_left', result[0][1]) profile.putProfileSetting('distance_right', result[1][0]) profile.putProfileSettingNumpy('normal_right', result[1][1]) self.platformExtrinsics.setCallbacks( None, lambda p: wx.CallAfter(self.progressPlatformCalibration, p), lambda r: wx.CallAfter(self.afterPlatformCalibration, r)) self.platformExtrinsics.start() else: if result == Error.CalibrationError: self.resultLabel.SetLabel( _("Error in lasers: please connect the lasers and try again" )) dlg = wx.MessageDialog( self, _("Laser Calibration failed. Please try again"), _(result), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() self.skipButton.Enable() self.onFinishCalibration()
def onScanTypeComboBoxChanged(self, event): value = self.scanTypeDict[event.GetEventObject().GetValue()] profile.putProfileSetting('scan_type', value) if value == 'Simple Scan': self.driver.camera.setExposure(profile.getProfileSettingInteger('laser_exposure_scanning')) elif value == 'Texture Scan': self.driver.camera.setExposure(profile.getProfileSettingInteger('color_exposure_scanning'))
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 onScanTypeComboBoxChanged(self, event): value = self.scanTypeDict[event.GetEventObject().GetValue()] profile.putProfileSetting('scan_type', value) if value == 'Simple Scan': self.driver.camera.setExposure( profile.getProfileSettingInteger('laser_exposure_scanning')) elif value == 'Texture Scan': self.driver.camera.setExposure( profile.getProfileSettingInteger('color_exposure_scanning'))
def onSliderTracked(self, event): if self.flagFirstMove: value = profile.getProfileSettingInteger(self.name) self.undoValues.append(value) if self.appendUndoCallback is not None: self.appendUndoCallback(self) self.flagFirstMove = False value = self.control.GetValue() profile.putProfileSetting(self.name, value) self._updateEngine(value)
def onComboBoVideoViewsSelect(self, event): selectedView = { _("Laser"): 'laser', _("Gray"): 'gray', _("Line"): 'line', _("Color"): 'color' }.get(self.comboVideoViews.GetValue()) self.currentScan.setImageType(selectedView) profile.putProfileSetting('img_type', selectedView)
def onResolutionComboBoxChanged(self, event): value = event.GetEventObject().GetValue() if value == _("High"): value = -0.45 elif value == _("Medium"): value = -0.9 elif value == _("Low"): value = -1.8 profile.putProfileSetting('step_degrees_scanning', value) self.pcg.setDegrees(value)
def onColorPicker(self): data = wx.ColourData() data.SetColour(self.simpleScan.color) dialog = wx.ColourDialog(self, data) dialog.GetColourData().SetChooseFull(True) if dialog.ShowModal() == wx.ID_OK: data = dialog.GetColourData() color = data.GetColour().Get() self.simpleScan.setColor(color) profile.putProfileSetting('point_cloud_color', "".join(map(chr, color)).encode('hex')) dialog.Destroy()
def setPatternDistance(self, patternDistance): profile.putProfileSetting('pattern_distance', patternDistance) patternRows = profile.getProfileSettingInteger('pattern_rows') patternColumns = profile.getProfileSettingInteger('pattern_columns') squareWidth = profile.getProfileSettingInteger('square_width') self.cameraIntrinsics.setPatternParameters(patternRows, patternColumns, squareWidth, patternDistance) self.simpleLaserTriangulation.setPatternParameters(patternRows, patternColumns, squareWidth, patternDistance) self.laserTriangulation.setPatternParameters(patternRows, patternColumns, squareWidth, patternDistance) self.platformExtrinsics.setPatternParameters(patternRows, patternColumns, squareWidth, patternDistance)
def onResolutionComboBoxChanged(self, event): value = event.GetEventObject().GetValue() if value ==_("High"): value = -0.45 elif value ==_("Medium"): value = -0.9 elif value ==_("Low"): value = -1.8 profile.putProfileSetting('step_degrees_scanning', value) self.pcg.setDegrees(value)
def onSlider(self, event): value = profile.getProfileSettingInteger(self.name) self.undoValues.append(value) if self.appendUndoCallback is not None: self.appendUndoCallback(self) value = self.control.GetValue() profile.putProfileSetting(self.name, value) self._updateEngine(value) if self.releaseUndoCallback is not None: self.releaseUndoCallback()
def onLaserComboBoxChanged(self, event): value = self.laserDict[event.GetEventObject().GetValue()] profile.putProfileSetting('use_laser', value) useLeft = value == 'Left' or value == 'Both' useRight = value == 'Right' or value == 'Both' if useLeft: self.driver.board.setLeftLaserOn() else: self.driver.board.setLeftLaserOff() if useRight: self.driver.board.setRightLaserOn() else: self.driver.board.setRightLaserOff() self.pcg.setUseLaser(useLeft, useRight)
def onLaserComboBoxChanged(self, event): value = event.GetEventObject().GetValue() profile.putProfileSetting('use_laser', value) useLeft = value == _("Use Left Laser") or value == _("Use Both Laser") useRight = value == _("Use Right Laser") or value == _( "Use Both Laser") if useLeft: self.driver.board.setLeftLaserOn() else: self.driver.board.setLeftLaserOff() if useRight: self.driver.board.setRightLaserOn() else: self.driver.board.setRightLaserOff() self.pcg.setUseLaser(useLeft, useRight)
def onAutoCheckButtonClicked(self, event): if profile.getProfileSettingBool('adjust_laser'): profile.putProfileSetting('adjust_laser', False) dlg = wx.MessageDialog(self, _("It is recomended to adjust line lasers vertically.\nYou need to use the allen wrench.\nDo you want to adjust it now?"), _("Manual laser adjustment"), wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal() == wx.ID_YES dlg.Destroy() if result: self.driver.board.setLeftLaserOn() self.driver.board.setRightLaserOn() else: self.beforeAutoCheck() #-- Perform auto check self.autoCheck.setCallbacks(None, lambda p: wx.CallAfter(self.progressAutoCheck,p), lambda r: wx.CallAfter(self.afterAutoCheck,r)) self.autoCheck.start()
def onLuminosityComboBoxChanged(self, event): value = event.GetEventObject().GetValue() profile.putProfileSetting('luminosity', value) if value ==_("Low Luminosity"): value = 32 elif value ==_("Medium Luminosity"): value = 16 elif value ==_("High Luminosity"): value = 8 profile.putProfileSetting('exposure_control', value) profile.putProfileSetting('exposure_calibration', value) profile.putProfileSetting('exposure_scanning', value) self.driver.camera.setExposure(value)
def afterLaserCalibration(self, response): self.phase='platformCalibration' ret, result = response if ret: profile.putProfileSetting('distance_left', result[0][0]) profile.putProfileSettingNumpy('normal_left', result[0][1]) profile.putProfileSetting('distance_right', result[1][0]) profile.putProfileSettingNumpy('normal_right', result[1][1]) self.platformExtrinsics.setCallbacks(None, lambda p: wx.CallAfter(self.progressPlatformCalibration,p), lambda r: wx.CallAfter(self.afterPlatformCalibration,r)) self.platformExtrinsics.start() else: if result == Error.CalibrationError: self.resultLabel.SetLabel(_("Error in lasers: please connect the lasers and try again")) dlg = wx.MessageDialog(self, _("Laser Calibration failed. Please try again"), _(result), wx.OK|wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() self.skipButton.Enable() self.onFinishCalibration()
def setLuminosity(self, luminosity): profile.putProfileSetting('luminosity', luminosity) if luminosity =='Low': luminosity = 32 elif luminosity =='Medium': luminosity = 16 elif luminosity =='High': luminosity = 8 profile.putProfileSetting('exposure_control', luminosity) profile.putProfileSetting('exposure_calibration', luminosity) self.driver.camera.setExposure(luminosity)
def setLuminosity(self, luminosity): profile.putProfileSetting('luminosity', luminosity) if luminosity == 'Low': luminosity = 32 elif luminosity == 'Medium': luminosity = 16 elif luminosity == 'High': luminosity = 8 profile.putProfileSetting('exposure_control', luminosity) profile.putProfileSetting('exposure_calibration', luminosity) self.driver.camera.setExposure(luminosity)
def onSerialNameTextChanged(self, event): if len(self.serialNameCombo.GetValue()): profile.putProfileSetting('serial_name', self.serialNameCombo.GetValue())
def undo(self): if len(self.undoValues) > 0: value = self.undoValues.pop() profile.putProfileSetting(self.name, value) self.update(value)
def onBaudRateTextChanged(self, event): if self.baudRateCombo.GetValue() in self.baudRates: profile.putProfileSetting('baud_rate', int(self.baudRateCombo.GetValue()))
def onComboBoxChanged(self, event): value = self.keyDict[self.control.GetValue()] profile.putProfileSetting(self.name, value) self._updateEngine(value)
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 onBaudRateComboChanged(self, event): if self.baudRateCombo.GetValue() in self.baudRates: profile.putProfileSetting('baud_rate', int(self.baudRateCombo.GetValue()))
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 onBoardsComboChanged(self, event): profile.putProfileSetting('board', self.boardsCombo.GetValue())
def onCameraIdTextChanged(self, event): if len(self.cameraIdCombo.GetValue()): profile.putProfileSetting('camera_id', self.cameraIdCombo.GetValue())
def onInvertMotor(self, event): profile.putProfileSetting('invert_motor', self.invertMotorCheckBox.GetValue())
def onScanTypeComboBoxChanged(self, event): value = event.GetEventObject().GetValue() profile.putProfileSetting('scan_type', value)
def onInvertMotor(self, event): invert = self.invertMotorCheckBox.GetValue() profile.putProfileSetting('invert_motor', invert) self.driver.board.setInvertMotor(invert)
def onSerialNameComboChanged(self, event): if len(self.serialNameCombo.GetValue()): profile.putProfileSetting('serial_name', self.serialNameCombo.GetValue())
def onCameraIdComboChanged(self, event): if len(self.cameraIdCombo.GetValue()): profile.putProfileSetting('camera_id', self.cameraIdCombo.GetValue())
def onComboBoVideoViewsSelect(self, event): value = self.videoViewsDict[self.comboVideoViews.GetValue()] self.currentScan.setImageType(value) profile.putProfileSetting('img_type', value)
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()