Пример #1
0
    def finishCal(self):
        u"""calculates the ratio of the calibrated axis, saves it to the options object (not to a file!!)"""
        if self.calibration == None:
            self.showInfoMessage("Blad programu")
        elif self.calibration in ('X', 'Y'):

            #TODO: tu jest odwolanie do mediatora, koniecznie ustaw odpowiednie metody !!
            if self.calibration == 'X':
                przesuniecie = self.mediator.coordCounter.ticksX
            else:
                przesuniecie = self.mediator.coordCounter.ticksY

            self.showInfoMessage(
                _("General distance in axis %s: %s" %
                  (self.calibration, przesuniecie)))

            text, ok = QtGui.QInputDialog.getText(
                self, programName,
                _('Enter distance the input device has moved: '))
            if ok:
                calc = przesuniecie / float(text)
                if self.calibration == 'X': self.options.xRatio = calc
                elif self.calibration == 'Y': self.options.yRatio = calc
            self.showInfoMessage(
                _("Ticks on milimeter in axis ") + self.calibration +
                _(" is: %s") % calc)

        self.calibration = None
        self.setMeasuringMode()
        self.ui.menu.activate(7)
Пример #2
0
	def allowCalibrate(self):
		text, ok = QtGui.QInputDialog.getText(self, programName, _("""Enter below "SUWMIARKA". 
It is protection against accidentally changing of the calibration configuration.
Entering word other than "SUWMIARKA" or pressing Cancel key simply returns to the mail menu and doesn't allow calibration.
If you choose to allow calibrating, and then with any cause you would like to turn off allowing calibration, choose option """)
+_('Measuring mode'))
		if ok:
			if text == "SUWMIARKA":
				for i in (4,5):	self.ui.menu.activate(i)
Пример #3
0
	def saveRatio(self):
		u"""saves ratio to a file"""
		try:
			self.options.saveRatio()
		# if some problems occurred, show the info message
		except:
			self.showInfoMessage(_("Error during saving calibration data to file."))
		# else show message that everything was ok
		else:
			self.showInfoMessage(_("Calibration data saved correctly"))
Пример #4
0
	def askWanted(self, axis):
		text, ok = QtGui.QInputDialog.getText(self, programName, _('Distance to measure in %s axis:')%axis)
		name = {'X':'wantedX', 'Y':'wantedY'}
		try:
			# force converting to float
			text="%s.0" % text
			distance = float(eval(text))
			setattr(self, name[axis], distance)
		except:
			self.showInfoMessage(_("You entered inproper number. You can use arithmetic operators (+, -, * /)"))
		self.updateUi()
Пример #5
0
 def saveRatio(self):
     u"""saves ratio to a file"""
     try:
         self.options.saveRatio()
     # if some problems occurred, show the info message
     except:
         self.showInfoMessage(
             _("Error during saving calibration data to file."))
     # else show message that everything was ok
     else:
         self.showInfoMessage(_("Calibration data saved correctly"))
Пример #6
0
    def allowCalibrate(self):
        text, ok = QtGui.QInputDialog.getText(
            self, programName,
            _("""Enter below "SUWMIARKA". 
It is protection against accidentally changing of the calibration configuration.
Entering word other than "SUWMIARKA" or pressing Cancel key simply returns to the mail menu and doesn't allow calibration.
If you choose to allow calibrating, and then with any cause you would like to turn off allowing calibration, choose option """
              ) + _('Measuring mode'))
        if ok:
            if text == "SUWMIARKA":
                for i in (4, 5):
                    self.ui.menu.activate(i)
Пример #7
0
 def askWanted(self, axis):
     text, ok = QtGui.QInputDialog.getText(
         self, programName,
         _('Distance to measure in %s axis:') % axis)
     name = {'X': 'wantedX', 'Y': 'wantedY'}
     try:
         # force converting to float
         text = "%s.0" % text
         distance = float(eval(text))
         setattr(self, name[axis], distance)
     except:
         self.showInfoMessage(
             _("You entered inproper number. You can use arithmetic operators (+, -, * /)"
               ))
     self.updateUi()
Пример #8
0
	def cal(self, axis):
		u"""starts calibrating an axis"""
		self.ui.menu.activate(6)
		reply = QtGui.QMessageBox.information(self, programName, _("Starting calibration of axis: %s")%axis, QtGui.QMessageBox.Ok)
		if reply == QtGui.QMessageBox.Ok:
			self.reset()
			self.calibration = axis
Пример #9
0
 def mouseMoveEvent(self, event):
     try:
         self.mediator.coordChanged()
     except TickException, e:
         QtGui.QMessageBox.information(
             self, "", _("Inproper reading from input device."),
             QtGui.QMessageBox.Ok)
         self.reset()
Пример #10
0
 def cal(self, axis):
     u"""starts calibrating an axis"""
     self.ui.menu.activate(6)
     reply = QtGui.QMessageBox.information(
         self, programName,
         _("Starting calibration of axis: %s") % axis, QtGui.QMessageBox.Ok)
     if reply == QtGui.QMessageBox.Ok:
         self.reset()
         self.calibration = axis
Пример #11
0
	def updateUi(self):		
		u"""updates UI based on distX and distY values"""
		
		# global distance ran over detector in both axis
		formatedDistanceX, formatedDistanceY = "%.3F" % self.distX, "%.3F" % self.distY
		
		# natively show the distance ran over the detector
		textX, textY = formatedDistanceX, formatedDistanceY


		# update info about
		if self.mode.getMode() == "MEASURING":
			pass	


		# the calibrated axis doesn't show the global way ran
		elif self.mode.getMode() == "CAL_X": textX = _("calibration")
		elif self.mode.getMode() == "CAL_Y": textY = _("calibration")

		self.textX = "<font color=red size=4><b>" + textX + "</b></font>"


		# fill the data into labels

		from PyQt4 import Qt
		# showing total distance ran over cursor
		self.ui.lbWayX.setText(textX)
		self.ui.lbWayY.setText(textY)
		

		# calculate the remaining distance and show it
		remainingX = self.wantedX - self.distX
		remainingY = self.wantedY - self.distY
		self.ui.lbRemainingX.setText("%3.3F"%remainingX)
		self.ui.lbRemainingY.setText("%3.3F"%remainingY)

		# show the distance user wants to measure
		self.ui.lbWantedX.setText("%3.3F"%self.wantedX)
		self.ui.lbWantedY.setText("%3.3F"%self.wantedY)

		# show info about current working mode
		self.ui.lbMode.setText(str(self.mode.getMode()))
Пример #12
0
    def updateUi(self):
        u"""updates UI based on distX and distY values"""

        # global distance ran over detector in both axis
        formatedDistanceX, formatedDistanceY = "%.3F" % self.distX, "%.3F" % self.distY

        # natively show the distance ran over the detector
        textX, textY = formatedDistanceX, formatedDistanceY

        # update info about
        if self.mode.getMode() == "MEASURING":
            pass

        # the calibrated axis doesn't show the global way ran
        elif self.mode.getMode() == "CAL_X":
            textX = _("calibration")
        elif self.mode.getMode() == "CAL_Y":
            textY = _("calibration")

        self.textX = "<font color=red size=4><b>" + textX + "</b></font>"

        # fill the data into labels

        from PyQt4 import Qt
        # showing total distance ran over cursor
        self.ui.lbWayX.setText(textX)
        self.ui.lbWayY.setText(textY)

        # calculate the remaining distance and show it
        remainingX = self.wantedX - self.distX
        remainingY = self.wantedY - self.distY
        self.ui.lbRemainingX.setText("%3.3F" % remainingX)
        self.ui.lbRemainingY.setText("%3.3F" % remainingY)

        # show the distance user wants to measure
        self.ui.lbWantedX.setText("%3.3F" % self.wantedX)
        self.ui.lbWantedY.setText("%3.3F" % self.wantedY)

        # show info about current working mode
        self.ui.lbMode.setText(str(self.mode.getMode()))
Пример #13
0
	def finishCal(self):
		u"""calculates the ratio of the calibrated axis, saves it to the options object (not to a file!!)"""
		if self.calibration == None:
			self.showInfoMessage("Blad programu")
		elif self.calibration in ('X','Y'):


			#TODO: tu jest odwolanie do mediatora, koniecznie ustaw odpowiednie metody !!
			if self.calibration =='X': przesuniecie = self.mediator.coordCounter.ticksX
			else: przesuniecie = self.mediator.coordCounter.ticksY

			self.showInfoMessage(_("General distance in axis %s: %s"%(self.calibration, przesuniecie)))

			text, ok = QtGui.QInputDialog.getText(self, programName, _('Enter distance the input device has moved: '))
			if ok:
				calc = przesuniecie / float(text)
				if self.calibration == 'X':  self.options.xRatio = calc
				elif self.calibration =='Y': self.options.yRatio = calc
			self.showInfoMessage(_("Ticks on milimeter in axis ")+self.calibration+_(" is: %s")%calc)

		self.calibration = None
		self.setMeasuringMode()
		self.ui.menu.activate(7)
Пример #14
0
	def __init__(self, parent=None):

		# 
		QtGui.QWidget.__init__(self, parent)


		
#		from PyQt4 import QString
		self.ui = Ui_Form()
		self.ui.setupUi(self, [  (_('Reset'), self.reset),
					 (_('Measuring mode'), self.setMeasuringMode),
					 (_('Distance to measure in X axis'), self.askWantedX),
					 (_('Distance to measure in Y axis'), self.askWantedY),
					 (_('Calibrate Y axis'), self.calY),
					 (_('Calibrate X axis'), self.calX),
					 (_('Finish calibration'), self.finishCal),
					 (_('Save calibration'), self.saveRatio),
					 (_('Allow calibration'), self.allowCalibrate),
					])


		
		print 'main widget: ',self.centralWidget()
		self.centralWidget().setMouseTracking(True)
		# mode of working
		self.mode = Mode(self, ("MEASURING", "CAL_X", "CAL_Y"))

		# storing programs options
		self.options = Options()

		# object that manages all other objects :)
		self.mediator = Mediator(self.cursor(), self)




		# distance the user wants the device to travel
		self.wantedX, self.wantedY = 0.0, 0.0

		self.setMeasuringMode()
		# set default values
		self.reset()
Пример #15
0
    def __init__(self, parent=None):

        #
        QtGui.QWidget.__init__(self, parent)

        #		from PyQt4 import QString
        self.ui = Ui_Form()
        self.ui.setupUi(self, [
            (_('Reset'), self.reset),
            (_('Measuring mode'), self.setMeasuringMode),
            (_('Distance to measure in X axis'), self.askWantedX),
            (_('Distance to measure in Y axis'), self.askWantedY),
            (_('Calibrate Y axis'), self.calY),
            (_('Calibrate X axis'), self.calX),
            (_('Finish calibration'), self.finishCal),
            (_('Save calibration'), self.saveRatio),
            (_('Allow calibration'), self.allowCalibrate),
        ])

        print 'main widget: ', self.centralWidget()
        self.centralWidget().setMouseTracking(True)
        # mode of working
        self.mode = Mode(self, ("MEASURING", "CAL_X", "CAL_Y"))

        # storing programs options
        self.options = Options()

        # object that manages all other objects :)
        self.mediator = Mediator(self.cursor(), self)

        # distance the user wants the device to travel
        self.wantedX, self.wantedY = 0.0, 0.0

        self.setMeasuringMode()
        # set default values
        self.reset()
Пример #16
0
	def mouseMoveEvent(self, event):
		try:
			self.mediator.coordChanged()
		except TickException, e:
			QtGui.QMessageBox.information(self, "", _("Inproper reading from input device."), QtGui.QMessageBox.Ok)
			self.reset()
Пример #17
0
    def setupUi(self, Form, dct):

	self.menu = Menu(Form, dct)
	
	# labels showing info about current working mode
	self.lbModeDescription = QtGui.QLabel(_("Working mode"), Form)
	self.lbMode = QtGui.QLabel(Form)

	# v_box representing info about current working mode
	self.v_box_mode_widget = QtGui.QWidget(Form)
	self.v_box_mode = QtGui.QVBoxLayout(self.v_box_mode_widget)
	self.v_box_mode.addStretch(1)
	self.v_box_mode.addWidget(self.lbModeDescription)
	self.v_box_mode.addWidget(self.lbMode)
	self.v_box_mode_widget.resize(200,200)
	



	# lalbels showing the total way in mm in proper axises
        self.lbWayX = QtGui.QLabel(Form)
        self.lbWayY = QtGui.QLabel(Form)


	# labels showing how much distance the user should ran so that he ran all he wants TODO: przetlumacz to na poprawny angielski
	self.lbRemainingX = QtGui.QLabel(Form)
	self.lbRemainingY = QtGui.QLabel(Form)

	# how many of way a device should travel overall
	self.lbDescWantedX = QtGui.QLabel(_("Distance to measure: "), Form)
	self.lbDescWantedY = QtGui.QLabel(_("Distance to measure: "), Form)
	self.lbWantedX = QtGui.QLabel(Form)
	self.lbWantedY = QtGui.QLabel(Form)


	# labels descriptioning labels showing the total distance ran by the detector (mouse)
	self.lbDescWayX = QtGui.QLabel("X:", Form)
	self.lbDescWayY = QtGui.QLabel("Y:", Form)

	self.lbDescRX = QtGui.QLabel(_("distance left:"), Form)
	self.lbDescRY = QtGui.QLabel(_("distance left:"), Form)

	#
	# grouped information: axis name and how many millimeters the detector (mouse) has moved:
	#
	self.h_box_x_widget = QtGui.QWidget(Form)
	self.h_box_x = QtGui.QHBoxLayout(self.h_box_x_widget)
	self.h_box_x.addWidget(self.lbDescWantedX)
	self.h_box_x.addWidget(self.lbWantedX)


	self.h_box_y_widget = QtGui.QWidget(Form)
	self.h_box_y = QtGui.QHBoxLayout(self.h_box_y_widget)
	self.h_box_y.addWidget(self.lbDescWantedY)
	self.h_box_y.addWidget(self.lbWantedY)


	# information of all axis
	self.v_box_dist_widget = QtGui.QWidget(Form)
	self.v_box_dist = QtGui.QVBoxLayout(self.v_box_dist_widget)

	self.v_box_dist.addWidget(self.h_box_x_widget)
	self.v_box_dist.addWidget(self.h_box_y_widget)


	
	self.info_box_widget = QtGui.QWidget()
	self.info_box = QtGui.QVBoxLayout(self.info_box_widget)

	
	for w in(self.v_box_mode_widget, self.menu, self.v_box_dist_widget, QtGui.QLabel("\t\t\t",Form)): self.info_box.addWidget(w)

	self.distanceWidget = QtGui.QWidget()
	self.distance = QtGui.QVBoxLayout(self.distanceWidget)

	self.distanceXWidget = QtGui.QWidget()
	self.distanceX = QtGui.QHBoxLayout(self.distanceXWidget)
	for w in (self.lbDescWayX, self.lbWayX):self.distanceX.addWidget(w)

	self.distanceYWidget = QtGui.QWidget()
	self.distanceY = QtGui.QHBoxLayout(self.distanceYWidget)
	for w in (self.lbDescWayY, self.lbWayY):self.distanceY.addWidget(w)

	
	for w in (self.distanceXWidget, self.distanceYWidget):self.distance.addWidget(w)


	self.distanceRemainingWidget = QtGui.QWidget()
	self.distanceRemaining = QtGui.QVBoxLayout(self.distanceRemainingWidget)

	self.distanceRXW = QtGui.QWidget()
	self.distanceRX = QtGui.QHBoxLayout(self.distanceRXW)
	for w in (self.lbDescRX, self.lbRemainingX): self.distanceRX.addWidget(w)

	self.distanceRYW = QtGui.QWidget()
	self.distanceRY = QtGui.QHBoxLayout(self.distanceRYW)
	for w in(self.lbDescRY, self.lbRemainingY): self.distanceRY.addWidget(w)

	self.distanceRemaining.addWidget(self.distanceRXW)
	self.distanceRemaining.addWidget(self.distanceRYW)

	self.distanceWidget.setMouseTracking(True)
	self.lbWayX.setMouseTracking(True)
	self.distanceXWidget.setMouseTracking(True)

	self.main_widget = QtGui.QWidget()
	self.main = QtGui.QHBoxLayout()
	for widget in (self.distanceWidget, self.distanceRemainingWidget, self.info_box_widget):self.main.addWidget(widget)
	

	self.main.setGeometry(QtCore.QRect(100,100,600,600))
        Form.setObjectName("Form")
#	Form.setLayout(self.main)
        Form.resize(800, 800)

	self.main_widget.setLayout(self.main)
	Form.setCentralWidget(self.main_widget)
        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
	self.menu.show()

	self.modifyLabels()
	self.lbWayX.resize(200, 200)
Пример #18
0
    def setupUi(self, Form, dct):

        self.menu = Menu(Form, dct)

        # labels showing info about current working mode
        self.lbModeDescription = QtGui.QLabel(_("Working mode"), Form)
        self.lbMode = QtGui.QLabel(Form)

        # v_box representing info about current working mode
        self.v_box_mode_widget = QtGui.QWidget(Form)
        self.v_box_mode = QtGui.QVBoxLayout(self.v_box_mode_widget)
        self.v_box_mode.addStretch(1)
        self.v_box_mode.addWidget(self.lbModeDescription)
        self.v_box_mode.addWidget(self.lbMode)
        self.v_box_mode_widget.resize(200, 200)

        # lalbels showing the total way in mm in proper axises
        self.lbWayX = QtGui.QLabel(Form)
        self.lbWayY = QtGui.QLabel(Form)

        # labels showing how much distance the user should ran so that he ran all he wants TODO: przetlumacz to na poprawny angielski
        self.lbRemainingX = QtGui.QLabel(Form)
        self.lbRemainingY = QtGui.QLabel(Form)

        # how many of way a device should travel overall
        self.lbDescWantedX = QtGui.QLabel(_("Distance to measure: "), Form)
        self.lbDescWantedY = QtGui.QLabel(_("Distance to measure: "), Form)
        self.lbWantedX = QtGui.QLabel(Form)
        self.lbWantedY = QtGui.QLabel(Form)

        # labels descriptioning labels showing the total distance ran by the detector (mouse)
        self.lbDescWayX = QtGui.QLabel("X:", Form)
        self.lbDescWayY = QtGui.QLabel("Y:", Form)

        self.lbDescRX = QtGui.QLabel(_("distance left:"), Form)
        self.lbDescRY = QtGui.QLabel(_("distance left:"), Form)

        #
        # grouped information: axis name and how many millimeters the detector (mouse) has moved:
        #
        self.h_box_x_widget = QtGui.QWidget(Form)
        self.h_box_x = QtGui.QHBoxLayout(self.h_box_x_widget)
        self.h_box_x.addWidget(self.lbDescWantedX)
        self.h_box_x.addWidget(self.lbWantedX)

        self.h_box_y_widget = QtGui.QWidget(Form)
        self.h_box_y = QtGui.QHBoxLayout(self.h_box_y_widget)
        self.h_box_y.addWidget(self.lbDescWantedY)
        self.h_box_y.addWidget(self.lbWantedY)

        # information of all axis
        self.v_box_dist_widget = QtGui.QWidget(Form)
        self.v_box_dist = QtGui.QVBoxLayout(self.v_box_dist_widget)

        self.v_box_dist.addWidget(self.h_box_x_widget)
        self.v_box_dist.addWidget(self.h_box_y_widget)

        self.info_box_widget = QtGui.QWidget()
        self.info_box = QtGui.QVBoxLayout(self.info_box_widget)

        for w in (self.v_box_mode_widget, self.menu, self.v_box_dist_widget,
                  QtGui.QLabel("\t\t\t", Form)):
            self.info_box.addWidget(w)

        self.distanceWidget = QtGui.QWidget()
        self.distance = QtGui.QVBoxLayout(self.distanceWidget)

        self.distanceXWidget = QtGui.QWidget()
        self.distanceX = QtGui.QHBoxLayout(self.distanceXWidget)
        for w in (self.lbDescWayX, self.lbWayX):
            self.distanceX.addWidget(w)

        self.distanceYWidget = QtGui.QWidget()
        self.distanceY = QtGui.QHBoxLayout(self.distanceYWidget)
        for w in (self.lbDescWayY, self.lbWayY):
            self.distanceY.addWidget(w)

        for w in (self.distanceXWidget, self.distanceYWidget):
            self.distance.addWidget(w)

        self.distanceRemainingWidget = QtGui.QWidget()
        self.distanceRemaining = QtGui.QVBoxLayout(
            self.distanceRemainingWidget)

        self.distanceRXW = QtGui.QWidget()
        self.distanceRX = QtGui.QHBoxLayout(self.distanceRXW)
        for w in (self.lbDescRX, self.lbRemainingX):
            self.distanceRX.addWidget(w)

        self.distanceRYW = QtGui.QWidget()
        self.distanceRY = QtGui.QHBoxLayout(self.distanceRYW)
        for w in (self.lbDescRY, self.lbRemainingY):
            self.distanceRY.addWidget(w)

        self.distanceRemaining.addWidget(self.distanceRXW)
        self.distanceRemaining.addWidget(self.distanceRYW)

        self.distanceWidget.setMouseTracking(True)
        self.lbWayX.setMouseTracking(True)
        self.distanceXWidget.setMouseTracking(True)

        self.main_widget = QtGui.QWidget()
        self.main = QtGui.QHBoxLayout()
        for widget in (self.distanceWidget, self.distanceRemainingWidget,
                       self.info_box_widget):
            self.main.addWidget(widget)

        self.main.setGeometry(QtCore.QRect(100, 100, 600, 600))
        Form.setObjectName("Form")
        #	Form.setLayout(self.main)
        Form.resize(800, 800)

        self.main_widget.setLayout(self.main)
        Form.setCentralWidget(self.main_widget)
        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
        self.menu.show()

        self.modifyLabels()
        self.lbWayX.resize(200, 200)