Exemplo n.º 1
0
	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)
Exemplo n.º 2
0
	def __init__(self, parent, name, engineCallback=None):
		wx.Panel.__init__(self, parent)
		self.engineCallback = engineCallback
		self.appendUndoCallback = None
		self.releaseUndoCallback = None

		self.undoValues = []

		self.control = None

		self.name = name
		self.setting = profile.getProfileSettingObject(self.name)
Exemplo n.º 3
0
	def __init__(self, parent, name, engineCallback=None):
		wx.Panel.__init__(self, parent)
		self.engineCallback = engineCallback
		self.appendUndoCallback = None
		self.releaseUndoCallback = None

		self.undoValues = []

		self.control = None

		self.name = name
		self.setting = profile.getProfileSettingObject(self.name)
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
    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.))
Exemplo n.º 6
0
	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()
Exemplo n.º 7
0
    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()
Exemplo n.º 8
0
    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()
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
Arquivo: main.py Projeto: rp3d/ciclop
    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()
Exemplo n.º 11
0
	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)
Exemplo n.º 12
0
	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()
Exemplo n.º 13
0
    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()