Example #1
0
    def updatePCGProfile(self):
        self.pcg.resetTheta()
        self.pcg.setViewROI(profile.getMachineSettingBool('view_roi'))
        self.pcg.setROIDiameter(profile.getMachineSettingInteger('roi_diameter'))
        self.pcg.setROIWidth(profile.getMachineSettingInteger('roi_width'))
        self.pcg.setROIHeight(profile.getMachineSettingInteger('roi_height'))
        self.pcg.setROIDepth(profile.getMachineSettingInteger('roi_depth'))
        self.pcg.setDegrees(profile.getProfileSettingFloat('step_degrees_scanning'))
        resolution = profile.getProfileSetting('resolution_scanning')
        self.pcg.setResolution(int(resolution.split('x')[1]), int(resolution.split('x')[0]))
        useLaser = profile.getProfileSetting('use_laser')
        self.pcg.setUseLaser(useLaser == 'Left' or useLaser == 'Both',
                             useLaser == 'Right' or useLaser == 'Both')
        self.pcg.setCameraIntrinsics(profile.getProfileSettingNumpy('camera_matrix'),
                                     profile.getProfileSettingNumpy('distortion_vector'))
        self.pcg.setLaserTriangulation(profile.getProfileSettingNumpy('distance_left'),
                                       profile.getProfileSettingNumpy('normal_left'),
                                       profile.getProfileSettingNumpy('distance_right'),
                                       profile.getProfileSettingNumpy('normal_right'))
        self.pcg.setPlatformExtrinsics(profile.getProfileSettingNumpy('rotation_matrix'),
                                       profile.getProfileSettingNumpy('translation_vector'))

        scanType = profile.getProfileSetting('scan_type')
        if scanType == 'Simple Scan':
            self.scanningWorkbench.currentScan = self.simpleScan
            self.driver.camera.setExposure(profile.getProfileSettingInteger('laser_exposure_scanning'))
        elif scanType == 'Texture Scan':
            self.scanningWorkbench.currentScan = self.textureScan
            self.driver.camera.setExposure(profile.getProfileSettingInteger('color_exposure_scanning'))

        self.simpleScan.setFastScan(profile.getProfileSettingBool('fast_scan'))
        self.simpleScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning'))
        self.simpleScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning'))
        self.simpleScan.setImageType(profile.getProfileSetting('img_type'))
        self.simpleScan.setUseThreshold(profile.getProfileSettingBool('use_cr_threshold'))
        self.simpleScan.setThresholdValue(profile.getProfileSettingInteger('cr_threshold_value'))
        self.simpleScan.setColor(struct.unpack('BBB',profile.getProfileSetting('point_cloud_color').decode('hex')))

        self.textureScan.setFastScan(profile.getProfileSettingBool('fast_scan'))
        self.textureScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning'))
        self.textureScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning'))
        self.textureScan.setImageType(profile.getProfileSetting('img_type'))
        self.textureScan.setUseOpen(profile.getProfileSettingBool('use_open'))
        self.textureScan.setOpenValue(profile.getProfileSettingInteger('open_value'))
        self.textureScan.setUseThreshold(profile.getProfileSettingBool('use_threshold'))
        self.textureScan.setThresholdValue(profile.getProfileSettingInteger('threshold_value'))
Example #2
0
	def onRadioButtonChanged(self, event):
		self.undoValues.append(profile.getProfileSettingBool(self.name))
		value = self.control.GetValue()
		profile.putProfileSetting(self.name, value)
		self._updateEngine(value)
		if self.appendUndoCallback is not None:
			self.appendUndoCallback(self)
		if self.releaseUndoCallback is not None:
			self.releaseUndoCallback()
Example #3
0
 def updateDriverProfile(self):
     self.driver.camera.setCameraId(
         int(profile.getProfileSetting('camera_id')[-1:]))
     self.driver.board.setSerialName(
         profile.getProfileSetting('serial_name'))
     self.driver.board.setBaudRate(
         profile.getProfileSettingInteger('baud_rate'))
     self.driver.board.setInvertMotor(
         profile.getProfileSettingBool('invert_motor'))
Example #4
0
	def onRadioButtonChanged(self, event):
		self.undoValues.append(profile.getProfileSettingBool(self.name))
		value = self.control.GetValue()
		profile.putProfileSetting(self.name, value)
		self._updateEngine(value)
		if self.appendUndoCallback is not None:
			self.appendUndoCallback(self)
		if self.releaseUndoCallback is not None:
			self.releaseUndoCallback()
Example #5
0
    def onAutoCheckButtonClicked(self, event):
        if profile.getProfileSettingBool('adjust_laser'):
            profile.putProfileSetting('adjust_laser', False)
            dlg = wx.MessageDialog(self, _("It is recomended to adjust line lasers vertically.\nYou need to use the allen wrench.\nDo you want to adjust it now?"), _("Manual laser adjustment"), wx.YES_NO | wx.ICON_QUESTION)
            result = dlg.ShowModal() == wx.ID_YES
            dlg.Destroy()
            if result:
                self.driver.board.setLeftLaserOn()
                self.driver.board.setRightLaserOn()
        else:
            self.beforeAutoCheck()

            #-- Perform auto check
            self.autoCheck.setCallbacks(None,
                                        lambda p: wx.CallAfter(self.progressAutoCheck,p),
                                        lambda r: wx.CallAfter(self.afterAutoCheck,r))
            self.autoCheck.start()
Example #6
0
    def onAutoCheckButtonClicked(self, event):
        if profile.getProfileSettingBool('adjust_laser'):
            profile.putProfileSetting('adjust_laser', False)
            dlg = wx.MessageDialog(self, _("It is recomended to adjust line lasers vertically.\nYou need to use the allen wrench.\nDo you want to adjust it now?"), _("Manual laser adjustment"), wx.YES_NO | wx.ICON_QUESTION)
            result = dlg.ShowModal() == wx.ID_YES
            dlg.Destroy()
            if result:
                self.driver.board.setLeftLaserOn()
                self.driver.board.setRightLaserOn()
        else:
            self.beforeAutoCheck()

            #-- Perform auto check
            self.autoCheck.setCallbacks(None,
                                        lambda p: wx.CallAfter(self.progressAutoCheck,p),
                                        lambda r: wx.CallAfter(self.afterAutoCheck,r))
            self.autoCheck.start()
Example #7
0
File: main.py Project: rp3d/ciclop
    def updatePCGProfile(self):
            self.pcg.resetTheta()
            self.pcg.setViewROI(profile.getProfileSettingBool('view_roi'))
            self.pcg.setROIDiameter(profile.getProfileSettingInteger('roi_diameter'))
            self.pcg.setROIHeight(profile.getProfileSettingInteger('roi_height'))
            self.pcg.setDegrees(profile.getProfileSettingFloat('step_degrees_scanning'))
            resolution = profile.getProfileSetting('resolution_scanning')
            self.pcg.setResolution(int(resolution.split('x')[1]), int(resolution.split('x')[0]))
            useLaser = profile.getProfileSetting('use_laser')
            self.pcg.setUseLaser(useLaser == 'Left' or useLaser == 'Both',
                                 useLaser == 'Right' or useLaser == 'Both')
            self.pcg.setCameraIntrinsics(profile.getProfileSettingNumpy('camera_matrix'),
                                         profile.getProfileSettingNumpy('distortion_vector'))
            self.pcg.setLaserTriangulation(profile.getProfileSettingNumpy('distance_left'),
                                           profile.getProfileSettingNumpy('normal_left'),
                                           profile.getProfileSettingNumpy('distance_right'),
                                           profile.getProfileSettingNumpy('normal_right'))
            self.pcg.setPlatformExtrinsics(profile.getProfileSettingNumpy('rotation_matrix'),
                                           profile.getProfileSettingNumpy('translation_vector'))

            scanType = profile.getProfileSetting('scan_type')
            if scanType == 'Simple Scan':
                self.scanningWorkbench.currentScan = self.simpleScan
                self.driver.camera.setExposure(profile.getProfileSettingInteger('laser_exposure_scanning'))
            elif scanType == 'Texture Scan':
                self.scanningWorkbench.currentScan = self.textureScan
                self.driver.camera.setExposure(profile.getProfileSettingInteger('color_exposure_scanning'))

            self.simpleScan.setFastScan(profile.getProfileSettingBool('fast_scan'))
            self.simpleScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning'))
            self.simpleScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning'))
            self.simpleScan.setImageType(profile.getProfileSetting('img_type'))
            self.simpleScan.setUseThreshold(profile.getProfileSettingBool('use_cr_threshold'))
            self.simpleScan.setThresholdValue(profile.getProfileSettingInteger('cr_threshold_value'))
            self.simpleScan.setColor(struct.unpack('BBB',profile.getProfileSetting('point_cloud_color').decode('hex')))

            self.textureScan.setFastScan(profile.getProfileSettingBool('fast_scan'))
            self.textureScan.setSpeedMotor(profile.getProfileSettingInteger('feed_rate_scanning'))
            self.textureScan.setAccelerationMotor(profile.getProfileSettingInteger('acceleration_scanning'))
            self.textureScan.setImageType(profile.getProfileSetting('img_type'))
            self.textureScan.setUseOpen(profile.getProfileSettingBool('use_open'))
            self.textureScan.setOpenValue(profile.getProfileSettingInteger('open_value'))
            self.textureScan.setUseThreshold(profile.getProfileSettingBool('use_threshold'))
            self.textureScan.setThresholdValue(profile.getProfileSettingInteger('threshold_value'))
Example #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()
Example #9
0
	def updateProfile(self):
		if hasattr(self,'control'):
			value = profile.getProfileSettingBool(self.name)
			self.update(value)
Example #10
0
    def _drawMachine(self):
        glEnable(GL_BLEND)

        machine = profile.getMachineSetting('machine_type')
        if machine.startswith('ciclop'):

            glEnable(GL_CULL_FACE)
            #-- Draw Platform
            if machine not in self._platformMesh:
                mesh = meshLoader.loadMesh(
                    resources.getPathForMesh(machine + '_platform.stl'))
                if mesh is not None:
                    self._platformMesh[machine] = mesh
                else:
                    self._platformMesh[machine] = None
                self._platformMesh[machine]._drawOffset = numpy.array(
                    [0, 0, 8.05], numpy.float32)
            glColor4f(0.6, 0.6, 0.6, 0.5)
            self._objectShader.bind()
            self._renderObject(self._platformMesh[machine])
            self._objectShader.unbind()
            glDisable(GL_CULL_FACE)

        glDepthMask(False)

        size = numpy.array([
            profile.getProfileSettingFloat('roi_diameter'),
            profile.getProfileSettingFloat('roi_diameter'),
            profile.getProfileSettingFloat('roi_height')
        ], numpy.float32)

        if profile.getProfileSettingBool('view_roi'):
            polys = profile.getSizePolygons(size)
            height = profile.getProfileSettingFloat('roi_height')
            circular = profile.getMachineSetting('machine_shape') == 'Circular'
            # Draw the sides of the build volume.
            glBegin(GL_QUADS)
            for n in xrange(0, len(polys[0])):
                if not circular:
                    if n % 2 == 0:
                        glColor4ub(5, 171, 231, 96)
                    else:
                        glColor4ub(5, 171, 231, 64)
                else:
                    glColor4ub(5, 171, 231, 96)
                    #glColor4ub(200, 200, 200, 150)

                glVertex3f(polys[0][n][0], polys[0][n][1], height)
                glVertex3f(polys[0][n][0], polys[0][n][1], 0)
                glVertex3f(polys[0][n - 1][0], polys[0][n - 1][1], 0)
                glVertex3f(polys[0][n - 1][0], polys[0][n - 1][1], height)
            glEnd()

            #Draw bottom and top of build volume.
            glColor4ub(5, 171, 231, 150)  #128)
            #glColor4ub(200, 200, 200, 200)
            glBegin(GL_TRIANGLE_FAN)
            for p in polys[0][::-1]:
                glVertex3f(p[0], p[1], 0)
            glEnd()
            glBegin(GL_TRIANGLE_FAN)
            for p in polys[0][::-1]:
                glVertex3f(p[0], p[1], height)
            glEnd()

            #view center:
            center = self.getObjectCenterPos()
            quadric = gluNewQuadric()
            gluQuadricNormals(quadric, GLU_SMOOTH)
            gluQuadricTexture(quadric, GL_TRUE)
            glColor4ub(255, 0, 0, 255)
            #lower center:
            gluCylinder(quadric, 6, 6, 1, 32, 16)
            gluDisk(quadric, 0.0, 6, 32, 1)

            glTranslate(0, 0, height - 1)
            gluDisk(quadric, 0.0, 6, 32, 1)
            gluCylinder(quadric, 6, 6, 1, 32, 16)
            glTranslate(0, 0, -height + 1)

        polys = profile.getMachineSizePolygons()

        #-- Draw checkerboard
        if self._platformTexture is None:
            self._platformTexture = openglHelpers.loadGLTexture(
                'checkerboard.png')
            glBindTexture(GL_TEXTURE_2D, self._platformTexture)
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
        glColor4f(1, 1, 1, 0.5)
        glBindTexture(GL_TEXTURE_2D, self._platformTexture)
        glEnable(GL_TEXTURE_2D)
        glBegin(GL_TRIANGLE_FAN)
        for p in polys[0]:
            glTexCoord2f(p[0] / 20, p[1] / 20)
            glVertex3f(p[0], p[1], 0)
        glEnd()

        glDepthMask(True)
        glDisable(GL_BLEND)
Example #11
0
	def _drawMachine(self):
		glEnable(GL_BLEND)

		machine = profile.getMachineSetting('machine_type')
		if machine.startswith('ciclop'):

			glEnable(GL_CULL_FACE)
			#-- Draw Platform
			if machine not in self._platformMesh:
				mesh = meshLoader.loadMesh(resources.getPathForMesh(machine + '_platform.stl'))
				if mesh is not None:
					self._platformMesh[machine] = mesh
				else:
					self._platformMesh[machine] = None
				self._platformMesh[machine]._drawOffset = numpy.array([0,0,8.05], numpy.float32)
			glColor4f(0.6,0.6,0.6,0.5)
			self._objectShader.bind()
			self._renderObject(self._platformMesh[machine])
			self._objectShader.unbind()
			glDisable(GL_CULL_FACE)

		glDepthMask(False)
		
		size = numpy.array([profile.getProfileSettingFloat('roi_diameter'),
							profile.getProfileSettingFloat('roi_diameter'),
							profile.getProfileSettingFloat('roi_height')], numpy.float32)

		if profile.getProfileSettingBool('view_roi'):
			polys = profile.getSizePolygons(size)
			height = profile.getProfileSettingFloat('roi_height')
			circular = profile.getMachineSetting('machine_shape') == 'Circular'
			# Draw the sides of the build volume.
			glBegin(GL_QUADS)
			for n in xrange(0, len(polys[0])):
				if not circular:
					if n % 2 == 0:
						glColor4ub(5, 171, 231, 96)
					else:
						glColor4ub(5, 171, 231, 64)
				else:
					glColor4ub(5, 171, 231, 96)
					#glColor4ub(200, 200, 200, 150)

				glVertex3f(polys[0][n][0], polys[0][n][1], height)
				glVertex3f(polys[0][n][0], polys[0][n][1], 0)
				glVertex3f(polys[0][n-1][0], polys[0][n-1][1], 0)
				glVertex3f(polys[0][n-1][0], polys[0][n-1][1], height)
			glEnd()

			#Draw bottom and top of build volume.
			glColor4ub(5, 171, 231, 150)#128)
			#glColor4ub(200, 200, 200, 200)
			glBegin(GL_TRIANGLE_FAN)
			for p in polys[0][::-1]:
				glVertex3f(p[0], p[1], 0)
			glEnd()
			glBegin(GL_TRIANGLE_FAN)
			for p in polys[0][::-1]:
				glVertex3f(p[0], p[1], height)
			glEnd()

			quadric=gluNewQuadric();
			gluQuadricNormals(quadric, GLU_SMOOTH);
			gluQuadricTexture(quadric, GL_TRUE);
			glColor4ub(0, 100, 200, 150)
			
			gluCylinder(quadric,6,6,1,32,16);
			gluDisk(quadric, 0.0, 6, 32, 1); 

			glTranslate(0,0,height-1)
			gluDisk(quadric, 0.0, 6, 32, 1); 
			gluCylinder(quadric,6,6,1,32,16);
			glTranslate(0,0,-height+1)

		polys = profile.getMachineSizePolygons()
		
		#-- Draw checkerboard
		if self._platformTexture is None:
			self._platformTexture = openglHelpers.loadGLTexture('checkerboard.png')
			glBindTexture(GL_TEXTURE_2D, self._platformTexture)
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
		glColor4f(1,1,1,0.5)
		glBindTexture(GL_TEXTURE_2D, self._platformTexture)
		glEnable(GL_TEXTURE_2D)
		glBegin(GL_TRIANGLE_FAN)
		for p in polys[0]:
			glTexCoord2f(p[0]/20, p[1]/20)
			glVertex3f(p[0], p[1], 0)
		glEnd()
		glDisable(GL_TEXTURE_2D)

		glDepthMask(True)
		glDisable(GL_BLEND)
Example #12
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()
Example #13
0
	def updateProfile(self):
		if hasattr(self,'control'):
			value = profile.getProfileSettingBool(self.name)
			self.update(value)
Example #14
0
File: main.py Project: rp3d/ciclop
 def updateDriverProfile(self):
     self.driver.camera.setCameraId(int(profile.getProfileSetting('camera_id')[-1:]))
     self.driver.board.setSerialName(profile.getProfileSetting('serial_name'))
     self.driver.board.setBaudRate(profile.getProfileSettingInteger('baud_rate'))
     self.driver.board.setInvertMotor(profile.getProfileSettingBool('invert_motor'))
Example #15
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()
Example #16
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()