def __init__(self): super(RobPathUI, self).__init__() loadUi(os.path.join(path, 'resources', 'robviz.ui'), self) self.boxPlot.addWidget(MyViz()) self.qtParam = QtParam() self.qtPart = QtPart() self.qtScan = QtScan() self.qtPath = QtPath() self.tabWidget.addTab(self.qtParam, 'Parameters') self.tabWidget.addTab(self.qtPart, 'Part') self.tabWidget.addTab(self.qtScan, 'Scan') self.tabWidget.addTab(self.qtPath, 'Path') self.qtParam.accepted.connect(self.qtParamAccepted) self.qtPart.accepted.connect(self.qtPartAccepted) self.btnQuit.clicked.connect(self.btnQuitClicked) icon = QtGui.QIcon.fromTheme('application-exit') self.btnQuit.setIcon(icon) rospy.Subscriber( '/velocity', MsgVelocity, self.cb_velocity, queue_size=1)
class RobPathUI(QtGui.QMainWindow): def __init__(self): super(RobPathUI, self).__init__() loadUi(os.path.join(path, 'resources', 'robviz.ui'), self) self.boxPlot.addWidget(MyViz()) self.qtParam = QtParam() self.qtPart = QtPart() self.qtScan = QtScan() self.qtPath = QtPath() self.tabWidget.addTab(self.qtParam, 'Parameters') self.tabWidget.addTab(self.qtPart, 'Part') self.tabWidget.addTab(self.qtScan, 'Scan') self.tabWidget.addTab(self.qtPath, 'Path') self.qtParam.accepted.connect(self.qtParamAccepted) self.qtPart.accepted.connect(self.qtPartAccepted) self.btnQuit.clicked.connect(self.btnQuitClicked) icon = QtGui.QIcon.fromTheme('application-exit') self.btnQuit.setIcon(icon) rospy.Subscriber( '/velocity', MsgVelocity, self.cb_velocity, queue_size=1) def cb_velocity(self, msg_velocity): self.lblInfo.setText("Speed: %.1f mm/s" % (1000 * msg_velocity.speed)) def qtParamAccepted(self, params): [self.qtPath.insertCommand(cmd) for cmd in params] def qtPartAccepted(self, path): cmds = self.qtPath.jason.path2cmds(path) [self.qtPath.insertCommand(cmd) for cmd in cmds] self.tabWidget.setCurrentWidget(self.qtPath) def btnQuitClicked(self): QtCore.QCoreApplication.instance().quit()
def __init__(self): super(Robviz, self).__init__() loadUi(os.path.join(path, 'resources', 'robviz.ui'), self) rospy.Subscriber('/supervisor/status', MsgStatus, self.cbStatus, queue_size=1) self.boxPlot.addWidget(MyViz()) self.qtData = QtData(self) self.qtParam = QtParam(self) self.qtScan = QtScan(self) self.qtPart = QtPart(self) self.qtPath = QtPath(self) self.tabWidget.addTab(self.qtData, 'Data') self.tabWidget.addTab(self.qtParam, 'Params') self.tabWidget.addTab(self.qtScan, 'Scan') self.tabWidget.addTab(self.qtPart, 'Part') self.tabWidget.addTab(self.qtPath, 'Path') self.qtData.accepted.connect(self.qtDataAccepted) self.qtParam.accepted.connect(self.qtParamAccepted) self.qtScan.accepted.connect(self.qtScanAccepted) self.qtPart.accepted.connect(self.qtPartAccepted) self.btnQuit.setIcon(QtGui.QIcon.fromTheme('application-exit')) self.btnQuit.clicked.connect(self.btnQuitClicked) self.speed = 0 self.power = 0 self.running = False self.laser_on = False tmrInfo = QtCore.QTimer(self) tmrInfo.timeout.connect(self.updateStatus) tmrInfo.start(100)
class Robviz(QtGui.QMainWindow): def __init__(self): super(Robviz, self).__init__() loadUi(os.path.join(path, 'resources', 'robviz.ui'), self) rospy.Subscriber('/supervisor/status', MsgStatus, self.cbStatus, queue_size=1) self.boxPlot.addWidget(MyViz()) self.qtData = QtData(self) self.qtParam = QtParam(self) self.qtScan = QtScan(self) self.qtPart = QtPart(self) self.qtPath = QtPath(self) self.tabWidget.addTab(self.qtData, 'Data') self.tabWidget.addTab(self.qtParam, 'Params') self.tabWidget.addTab(self.qtScan, 'Scan') self.tabWidget.addTab(self.qtPart, 'Part') self.tabWidget.addTab(self.qtPath, 'Path') self.qtData.accepted.connect(self.qtDataAccepted) self.qtParam.accepted.connect(self.qtParamAccepted) self.qtScan.accepted.connect(self.qtScanAccepted) self.qtPart.accepted.connect(self.qtPartAccepted) self.btnQuit.setIcon(QtGui.QIcon.fromTheme('application-exit')) self.btnQuit.clicked.connect(self.btnQuitClicked) self.speed = 0 self.power = 0 self.running = False self.laser_on = False tmrInfo = QtCore.QTimer(self) tmrInfo.timeout.connect(self.updateStatus) tmrInfo.start(100) def cbStatus(self, msg_status): self.running = msg_status.running self.laser_on = msg_status.laser_on self.speed = msg_status.speed self.power = msg_status.power def updateStatus(self): self.lblSpeed.setText("Speed: %.1f mm/s" % (self.speed)) self.lblPower.setText("Power: %i W" % (self.power)) if self.running: self.lblStatus.setText('Running') self.lblStatus.setStyleSheet( "background-color: rgb(0, 255, 0); color: rgb(0, 0, 0);") else: self.lblStatus.setText('Stopped') self.lblStatus.setStyleSheet( "background-color: rgb(255, 0, 0); color: rgb(0, 0, 0);") if self.laser_on: self.lblLaser.setText('Laser ON') self.lblLaser.setStyleSheet( "background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);") else: self.lblLaser.setText('Laser OFF') self.lblLaser.setStyleSheet( "background-color: rgb(0, 0, 255); color: rgb(0, 0, 0);") def qtDataAccepted(self): self.tabWidget.setCurrentWidget(self.qtParam) def qtParamAccepted(self): self.tabWidget.setCurrentWidget(self.qtPart) def qtScanAccepted(self, path): print 'Path:', path commands = self.qtPath.jason.path2cmds(path) print 'Commands:', commands self.qtPath.loadCommands(commands) self.tabWidget.setCurrentWidget(self.qtPath) def qtPartAccepted(self, path): commands = self.qtPath.jason.path2cmds(path) self.qtPath.loadCommands(commands) self.tabWidget.setCurrentWidget(self.qtPath) def btnQuitClicked(self): QtCore.QCoreApplication.instance().quit()