def onLanguageComboChanged(self, event): if profile.getPreference( 'language') is not self.languageCombo.GetValue(): profile.putPreference('language', self.languageCombo.GetValue()) resources.setupLocalization(profile.getPreference('language')) wx.MessageBox( _("You have to restart the application to make the changes effective." ), 'Info', wx.OK | wx.ICON_INFORMATION)
def workbenchUpdate(self, layout=True): currentWorkbench = profile.getPreference('workbench') wb = {'Control workbench' : self.controlWorkbench, 'Calibration workbench' : self.calibrationWorkbench, 'Scanning workbench' : self.scanningWorkbench} waitCursor = wx.BusyCursor() self.menuFile.Enable(self.menuLoadModel.GetId(), currentWorkbench == 'Scanning workbench') self.menuFile.Enable(self.menuSaveModel.GetId(), currentWorkbench == 'Scanning workbench') self.menuFile.Enable(self.menuClearModel.GetId(), currentWorkbench == 'Scanning workbench') wb[currentWorkbench].updateProfileToAllControls() wb[currentWorkbench].combo.SetValue(_(currentWorkbench)) if layout: for key in wb: if wb[key] is not None: if key == currentWorkbench: wb[key].Hide() wb[key].Show() else: wb[key].Hide() self.Layout() del waitCursor gc.collect()
def __init__(self, parent): super(WelcomeWindow, self).__init__(parent, size=(640 + 120, 480 + 40), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER) self.parent = parent self.lastFiles = eval(profile.getPreference('last_files')) header = Header(self) content = Content(self) checkBoxShow = wx.CheckBox(self, label=_("Don't show this dialog again"), style=wx.ALIGN_LEFT) checkBoxShow.SetValue(not profile.getPreferenceBool('show_welcome')) checkBoxShow.Bind(wx.EVT_CHECKBOX, self.onCheckBoxChanged) self.Bind(wx.EVT_CLOSE, self.onClose) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(header, 2, wx.ALL | wx.EXPAND, 1) vbox.Add(content, 3, wx.ALL | wx.EXPAND ^ wx.BOTTOM, 20) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add((0, 0), 1, wx.ALL | wx.EXPAND, 0) hbox.Add(checkBoxShow, 0, wx.ALL, 0) vbox.Add(hbox, 0, wx.ALL | wx.EXPAND, 15) self.SetSizer(vbox) self.Centre() self.ShowModal()
def afterSplashCallback(self): #-- Load Profile and Preferences profile.loadPreferences(os.path.join(self.basePath, 'preferences.ini')) profile.loadProfile(os.path.join(self.basePath, 'current-profile.ini')) #-- Load Language resources.setupLocalization(profile.getPreference('language')) #-- Create Main Window self.mainWindow = MainWindow() #-- Check for updates if profile.getPreferenceBool('check_for_updates') and version.checkForUpdates(): v = VersionWindow(self.mainWindow) if v.download: return #-- Show Main Window self.SetTopWindow(self.mainWindow) self.mainWindow.Show() if profile.getPreferenceBool('show_welcome'): #-- Create Welcome Window WelcomeWindow(self.mainWindow) setFullScreenCapable(self.mainWindow) if sys.isDarwin(): wx.CallAfter(self.StupidMacOSWorkaround)
def __init__(self, parent): super(WelcomeWindow, self).__init__(parent, size=(640+120,480+40), style=wx.DEFAULT_FRAME_STYLE^wx.RESIZE_BORDER) self.parent = parent self.lastFiles = eval(profile.getPreference('last_files')) header = Header(self) content = Content(self) checkBoxShow = wx.CheckBox(self, label=_("Don't show this dialog again"), style=wx.ALIGN_LEFT) checkBoxShow.SetValue(not profile.getPreferenceBool('show_welcome')) checkBoxShow.Bind(wx.EVT_CHECKBOX, self.onCheckBoxChanged) self.Bind(wx.EVT_CLOSE, self.onClose) #-- Layout vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(header, 2, wx.ALL|wx.EXPAND, 1) vbox.Add(content, 3, wx.ALL|wx.EXPAND^wx.BOTTOM, 20) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add((0,0), 1, wx.ALL|wx.EXPAND, 0) hbox.Add(checkBoxShow, 0, wx.ALL, 0) vbox.Add(hbox, 0, wx.ALL|wx.EXPAND, 15) self.SetSizer(vbox) self.Centre() self.ShowModal()
def __init__(self, parent): wx.Panel.__init__(self, parent) titleText = wx.StaticText(self, label=_("Open recent file")) titleText.SetFont( ( wx.Font( wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_NORMAL, ) ) ) lastFiles = eval(profile.getPreference("last_files")) lastFiles.reverse() vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(titleText, 0, wx.BOTTOM | wx.CENTER, 10) for path in lastFiles: button = wx.Button(self, label=os.path.basename(path), name=path) button.Bind(wx.EVT_BUTTON, self.onButtonPressed) vbox.Add(button, 0, wx.ALL | wx.EXPAND, 5) self.SetSizer(vbox) self.Layout()
def afterSplashCallback(self): #-- Load Profile and Preferences profile.loadPreferences(os.path.join(self.basePath, 'preferences.ini')) profile.loadProfile(os.path.join(self.basePath, 'current-profile.ini')) profile.loadMachineSettings( os.path.join(self.basePath, profile.getMachineSettingFileName())) #-- Load Language resources.setupLocalization(profile.getPreference('language')) #-- Create Main Window self.mainWindow = MainWindow() #-- Check for updates if profile.getPreferenceBool( 'check_for_updates') and version.checkForUpdates(): v = VersionWindow(self.mainWindow) if v.download: return #-- Show Main Window self.SetTopWindow(self.mainWindow) self.mainWindow.Show() if profile.getPreferenceBool('show_welcome'): #-- Create Welcome Window WelcomeWindow(self.mainWindow) setFullScreenCapable(self.mainWindow) if sys.isDarwin(): wx.CallAfter(self.StupidMacOSWorkaround)
def onOpenProfile(self, event): """ """ dlg=wx.FileDialog(self, _("Select profile file to load"), os.path.split(profile.getPreference('last_profile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("ini files (*.ini)|*.ini") if dlg.ShowModal() == wx.ID_OK: profileFile = dlg.GetPath() profile.loadProfile(profileFile) self.updateProfileToAllControls() dlg.Destroy()
def onComboBoxWorkbenchSelected(self, event): """ """ if _(profile.getPreference( 'workbench')) != event.GetEventObject().GetValue(): profile.putPreference( 'workbench', self.workbenchDict[event.GetEventObject().GetValue()]) profile.saveProfile( os.path.join(profile.getBasePath(), 'current-profile.ini')) self.workbenchUpdate()
def onSaveProfile(self, event): """ """ dlg=wx.FileDialog(self, _("Select profile file to save"), os.path.split(profile.getPreference('last_profile'))[0], style=wx.FD_SAVE) dlg.SetWildcard("ini files (*.ini)|*.ini") if dlg.ShowModal() == wx.ID_OK: profileFile = dlg.GetPath() if not profileFile.endswith('.ini'): if platform.system() == 'Linux': #hack for linux, as for some reason the .ini is not appended. profileFile += '.ini' profile.saveProfile(profileFile) dlg.Destroy()
def onSaveProfile(self, event): """ """ dlg=wx.FileDialog(self, _("Select profile file to save"), os.path.split(profile.getPreference('last_profile'))[0], style=wx.FD_SAVE) dlg.SetWildcard("ini files (*.ini)|*.ini") if dlg.ShowModal() == wx.ID_OK: profileFile = dlg.GetPath() if not profileFile.endswith('.ini'): if sys.isLinux(): #hack for linux, as for some reason the .ini is not appended. profileFile += '.ini' profile.saveProfile(profileFile) dlg.Destroy()
def onComboBoxWorkbenchSelected(self, event): """ """ currentWorkbench = profile.getPreference('workbench') for key in self.workbenchList: if self.workbenchList[key] == str( event.GetEventObject().GetValue()): if key is not None: profile.putPreference('workbench', key) if key != currentWorkbench: profile.saveProfile( os.path.join(profile.getBasePath(), 'current-profile.ini')) self.workbenchUpdate()
def afterSplashCallback(self): #-- Load Profile and Preferences profile.loadPreferences(os.path.join(self.basePath, 'preferences.ini')) profile.loadProfile(os.path.join(self.basePath, 'current-profile.ini')) #-- Load Language resources.setupLocalization(profile.getPreference('language')) #-- Create Main Window mainWindow = MainWindow() if profile.getPreferenceBool('show_welcome'): #-- Create Welcome Window welcome = WelcomeWindow(mainWindow)
def __init__(self, parent): super(Wizard, self).__init__(parent, title="", size=(640 + 120, 480 + 40)) self.parent = parent self.driver = Driver.Instance() self.currentWorkbench = profile.getPreference('workbench') self.connectionPage = ConnectionPage( self, buttonPrevCallback=self.onConnectionPagePrevClicked, buttonNextCallback=self.onConnectionPageNextClicked) self.calibrationPage = CalibrationPage( self, buttonPrevCallback=self.onCalibrationPagePrevClicked, buttonNextCallback=self.onCalibrationPageNextClicked) self.scanningPage = ScanningPage( self, buttonPrevCallback=self.onScanningPagePrevClicked, buttonNextCallback=self.onScanningPageNextClicked) pages = [self.connectionPage, self.calibrationPage, self.scanningPage] self.connectionPage.intialize(pages) self.calibrationPage.intialize(pages) self.scanningPage.intialize(pages) self.connectionPage.Show() self.calibrationPage.Hide() self.scanningPage.Hide() self.driver.board.setUnplugCallback( lambda: wx.CallAfter(self.onBoardUnplugged)) self.driver.camera.setUnplugCallback( lambda: wx.CallAfter(self.onCameraUnplugged)) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.connectionPage, 1, wx.ALL | wx.EXPAND, 0) hbox.Add(self.calibrationPage, 1, wx.ALL | wx.EXPAND, 0) hbox.Add(self.scanningPage, 1, wx.ALL | wx.EXPAND, 0) self.SetSizer(hbox) self.Bind(wx.EVT_CLOSE, lambda e: self.onExit()) self.Centre() self.ShowModal()
def onLoadModel(self, event): lastFile = os.path.split(profile.getPreference('last_file'))[0] dlg = wx.FileDialog(self, _("Open 3D model"), lastFile, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) wildcardList = ';'.join(map(lambda s: '*' + s, meshLoader.loadSupportedExtensions())) wildcardFilter = "All (%s)|%s;%s" % (wildcardList, wildcardList, wildcardList.upper()) wildcardList = ';'.join(map(lambda s: '*' + s, meshLoader.loadSupportedExtensions())) wildcardFilter += "|Mesh files (%s)|%s;%s" % (wildcardList, wildcardList, wildcardList.upper()) dlg.SetWildcard(wildcardFilter) if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() if filename is not None: self.scanningWorkbench.sceneView.loadFile(filename) self.appendLastFile(filename) dlg.Destroy()
def onSaveModel(self, event): if self.scanningWorkbench.sceneView._object is None: return dlg = wx.FileDialog(self, _("Save 3D model"), os.path.split(profile.getPreference('last_file'))[0], style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) fileExtensions = meshLoader.saveSupportedExtensions() wildcardList = ';'.join(map(lambda s: '*' + s, fileExtensions)) wildcardFilter = "Mesh files (%s)|%s;%s" % (wildcardList, wildcardList, wildcardList.upper()) dlg.SetWildcard(wildcardFilter) if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() if not filename.endswith('.ply'): if platform.system() == 'Linux': #hack for linux, as for some reason the .ply is not appended. filename += '.ply' meshLoader.saveMesh(filename, self.scanningWorkbench.sceneView._object) self.appendLastFile(filename) dlg.Destroy()
def updateStatus(self, status): if status: if profile.getPreference('workbench') != 'calibration': profile.putPreference('workbench', 'calibration') self.GetParent().parent.workbenchUpdate(False) self.videoView.play() self.calibrateButton.Enable() self.driver.board.setLeftLaserOff() self.driver.board.setRightLaserOff() else: self.videoView.stop() self.gauge.SetValue(0) self.gauge.Show() self.prevButton.Enable() self.calibrateButton.Disable() self.cancelButton.Disable()
def onSaveModel(self, event): if self.scanningWorkbench.sceneView._object is None: return dlg = wx.FileDialog(self, _("Save 3D model"), os.path.split(profile.getPreference('last_file'))[0], style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) fileExtensions = meshLoader.saveSupportedExtensions() wildcardList = ';'.join(map(lambda s: '*' + s, fileExtensions)) wildcardFilter = "Mesh files (%s)|%s;%s" % (wildcardList, wildcardList, wildcardList.upper()) dlg.SetWildcard(wildcardFilter) if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() if not filename.endswith('.ply'): if sys.isLinux(): #hack for linux, as for some reason the .ply is not appended. filename += '.ply' meshLoader.saveMesh(filename, self.scanningWorkbench.sceneView._object) self.appendLastFile(filename) dlg.Destroy()
def __init__(self, parent): wx.Panel.__init__(self, parent) titleText = wx.StaticText(self, label=_("Open recent file")) titleText.SetFont((wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_NORMAL))) lastFiles = eval(profile.getPreference('last_files')) lastFiles.reverse() vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(titleText, 0, wx.BOTTOM|wx.CENTER, 10) for path in lastFiles: button = wx.Button(self, label=os.path.basename(path), name=path) button.Bind(wx.EVT_BUTTON, self.onButtonPressed) vbox.Add(button, 0, wx.ALL|wx.EXPAND, 5) self.SetSizer(vbox) self.Layout()
def updateStatus(self, status): if status: if profile.getPreference('workbench') != 'Calibration workbench': profile.putPreference('workbench', 'Calibration workbench') self.GetParent().parent.workbenchUpdate(False) self.videoView.play() self.calibrateButton.Enable() self.skipButton.Enable() self.driver.board.setLeftLaserOff() self.driver.board.setRightLaserOff() else: self.videoView.stop() self.gauge.SetValue(0) self.gauge.Show() self.prevButton.Enable() self.skipButton.Disable() self.nextButton.Disable() self.calibrateButton.Disable() self.cancelButton.Disable()
def __init__(self, parent): super(Wizard, self).__init__(parent, title="", size=(640+120,480+40)) self.parent = parent self.driver = Driver.Instance() self.currentWorkbench = profile.getPreference('workbench') self.connectionPage = ConnectionPage(self, buttonPrevCallback=self.onConnectionPagePrevClicked, buttonNextCallback=self.onConnectionPageNextClicked) self.calibrationPage = CalibrationPage(self, buttonPrevCallback=self.onCalibrationPagePrevClicked, buttonNextCallback=self.onCalibrationPageNextClicked) self.scanningPage = ScanningPage(self, buttonPrevCallback=self.onScanningPagePrevClicked, buttonNextCallback=self.onScanningPageNextClicked) pages = [self.connectionPage, self.calibrationPage, self.scanningPage] self.connectionPage.intialize(pages) self.calibrationPage.intialize(pages) self.scanningPage.intialize(pages) self.connectionPage.Show() self.calibrationPage.Hide() self.scanningPage.Hide() self.driver.board.setUnplugCallback(lambda: wx.CallAfter(self.onBoardUnplugged)) self.driver.camera.setUnplugCallback(lambda: wx.CallAfter(self.onCameraUnplugged)) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.connectionPage, 1, wx.ALL|wx.EXPAND, 0) hbox.Add(self.calibrationPage, 1, wx.ALL|wx.EXPAND, 0) hbox.Add(self.scanningPage, 1, wx.ALL|wx.EXPAND, 0) self.SetSizer(hbox) self.Bind(wx.EVT_CLOSE, lambda e: self.onExit()) self.Centre() self.ShowModal()
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 __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 onLanguageComboChanged(self, event): if profile.getPreference('language') is not self.languageCombo.GetValue(): profile.putPreference('language', self.languageCombo.GetValue()) wx.MessageBox(_("You have to restart the application to make the changes effective."), 'Info', wx.OK | wx.ICON_INFORMATION)
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(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): 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 onComboBoxWorkbenchSelected(self, event): """ """ if _(profile.getPreference('workbench')) != event.GetEventObject().GetValue(): profile.putPreference('workbench', self.workbenchDict[event.GetEventObject().GetValue()]) profile.saveProfile(os.path.join(profile.getBasePath(), 'current-profile.ini')) self.workbenchUpdate()