def __init__(self): super(PostProcMainWidget, self).__init__() # init the GUI components: self.bagWidget = BagWidget(self) self.bagFiles = self.bagWidget.getBagFiles() self.plotWidget = PlotWidget(self.bagFiles, self) self.__addPlotBtn = QPushButton("Add new Graph") self.__delPlotBtn = QPushButton("Delete Graph") self.__qualityBtn = QPushButton("Compute Data Quality") # connect signals to slots: self.__addPlotBtn.clicked.connect(self.openNewGraphDialog) self.__delPlotBtn.clicked.connect(self.openDelGraphDialog) self.__qualityBtn.clicked.connect(self.openQualityDialog) # setup the layout: layout = QGridLayout() # (rowIndex, rowStretch) layout.setRowStretch( 0, 0) # controls behavior when changing the window size # (widget, fromRow, fromColumn, rowSpan, columnSpan) layout.addWidget(self.bagWidget, 0, 0, 1, 3) layout.setRowStretch(1, 0) layout.addWidget(self.__addPlotBtn, 1, 0, 1, 1) layout.addWidget(self.__delPlotBtn, 1, 1, 1, 1) layout.addWidget(self.__qualityBtn, 1, 2, 1, 1) layout.setRowStretch(2, 1) layout.addWidget(self.plotWidget, 2, 0, 1, 3) self.setLayout(layout)
def initUI(self): # sve sto zelimo u prozoru # ******* Create central Widget ******** # self.centralwidget = QtWidgets.QWidget(self) self.centralwidget.setObjectName("centralwidget") # ******* Create widgets ******* # self.PortWidget = PortWidget(self) self.ControlWidget = ControlWidget(self) self.PlotWidget = PlotWidget(self) self.RectangleWidget = RectangleWidget(self) self.StatisticsWidget = StatisticsWidget(self) # ****** Create central layout and add widgets to it ****** # centralLayout = QtWidgets.QGridLayout() centralLayout.setColumnStretch(0, 1) centralLayout.setColumnStretch(1, 3) centralLayout.setColumnStretch(2, 2) centralLayout.setRowStretch(0, 1) centralLayout.setRowStretch(1, 5) #todo vratit sa 5 na 2 centralLayout.addWidget(self.PortWidget, 0, 0) centralLayout.addWidget(self.ControlWidget, 0, 1) centralLayout.addWidget(self.PlotWidget, 1, 1) centralLayout.addWidget(self.RectangleWidget, 1, 0) centralLayout.addWidget(self.StatisticsWidget, 1, 2) # *********** Window properties ************ # self.centralwidget.setLayout(centralLayout) self.setCentralWidget(self.centralwidget) self.setGeometry(200, 100, 900, 500) #todo maybe vratit sirinu na 1000 self.setWindowTitle("Biomehanička vaga")
def drawData(self,qp): #lets sample the function and draw the points step = 30.0/float(self.sampleCount) self.clear_data() for func in self.funcs: self.point_sets.append( [[-15.0 +(float(i)*step), func.evaluate(-15.0 +(float(i)*step))] for i in xrange(self.sampleCount)]) PlotWidget.drawData(self,qp)
def __init__(self, field, field_color, fun_list, fun_color): """ @param field: DirectionField, the field we want to display @param field_color: int[3] each range 0-255, the color we wish to use for the field @param fun_list: [InitialValuePropblemFunction], list of functions to be displayed @param fun_color: [int[3]] , list of color, one for each function """ PlotWidget.__init__(self) self.field = field self.field_color = field_color self.initial_funcs = fun_list self.initial_colors = fun_color
def drawData(self, qp): #lets sample the function and draw the points step = 30.0 / float(self.sampleCount) self.clear_data() for func in self.funcs: self.point_sets.append([[ -15.0 + (float(i) * step), func.evaluate(-15.0 + (float(i) * step)) ] for i in xrange(self.sampleCount)]) PlotWidget.drawData(self, qp)
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.al = bricklet_ambient_light.AmbientLight(self.uid) self.ipcon.add_device(self.al) self.version = '.'.join(map(str, self.al.get_version()[1])) self.qtcb_illuminance.connect(self.cb_illuminance) self.al.register_callback(self.al.CALLBACK_ILLUMINANCE, self.qtcb_illuminance.emit) self.illuminance_label = IlluminanceLabel('Illuminance: ') self.alf = AmbientLightFrame() self.current_value = 0 plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Illuminance [lx]', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.illuminance_label) layout_h.addWidget(self.alf) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.hum = bricklet_humidity.Humidity(self.uid) self.ipcon.add_device(self.hum) self.version = '.'.join(map(str, self.hum.get_version()[1])) self.qtcb_humidity.connect(self.cb_humidity) self.hum.register_callback(self.hum.CALLBACK_HUMIDITY, self.qtcb_humidity.emit) self.humidity_label = HumidityLabel('Humidity: ') self.current_value = 0 plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Relative Humidity [%RH]', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.humidity_label) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.lp = bricklet_linear_poti.LinearPoti(self.uid) self.ipcon.add_device(self.lp) self.version = '.'.join(map(str, self.lp.get_version()[1])) self.qtcb_position.connect(self.cb_position) self.lp.register_callback(self.lp.CALLBACK_POSITION, self.qtcb_position.emit) self.slider = QSlider(Qt.Horizontal) self.slider.setRange(0, 100) self.position_label = PositionLabel('Position: ') self.current_value = 0 plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Position', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.position_label) layout_h.addWidget(self.slider) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.tem = bricklet_temperature.Temperature(self.uid) self.ipcon.add_device(self.tem) self.version = '.'.join(map(str, self.tem.get_version()[1])) self.qtcb_temperature.connect(self.cb_temperature) self.tem.register_callback(self.tem.CALLBACK_TEMPERATURE, self.qtcb_temperature.emit) self.temperature_label = TemperatureLabel() self.cb_temperature(self.tem.get_temperature()) self.current_value = 0 plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Temperature [%cC]' % 0xB0, plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.temperature_label) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.vol = bricklet_voltage.Voltage(self.uid) self.ipcon.add_device(self.vol) self.version = '.'.join(map(str, self.vol.get_version()[1])) self.qtcb_voltage.connect(self.cb_voltage) self.vol.register_callback(self.vol.CALLBACK_VOLTAGE, self.qtcb_voltage.emit) self.voltage_label = CurrentLabel('Voltage: ') self.current_value = 0 plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Voltage [mV]', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.voltage_label) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.dist = bricklet_distance_ir.DistanceIR(self.uid) self.ipcon.add_device(self.dist) self.version = '.'.join(map(str, self.dist.get_version()[1])) self.qtcb_distance.connect(self.cb_distance) self.dist.register_callback(self.dist.CALLBACK_DISTANCE, self.qtcb_distance.emit) self.qtcb_analog.connect(self.cb_analog) self.dist.register_callback(self.dist.CALLBACK_ANALOG_VALUE, self.qtcb_analog.emit) self.analog_value = 0 self.counter = 0 self.distance_label = DistanceLabel('Distance: ') self.analog_label = AnalogLabel('Analog value: ') self.sample_layout = QHBoxLayout() self.sample_label = QLabel('Sample Points:') self.sample_edit = QLineEdit() self.sample_file = QPushButton("File..") self.sample_save = QPushButton("Save") self.sample_file.pressed.connect(self.sample_file_pressed) self.sample_save.pressed.connect(self.sample_save_pressed) self.sample_layout.addWidget(self.sample_label) self.sample_layout.addWidget(self.sample_edit) self.sample_layout.addWidget(self.sample_file) self.sample_layout.addWidget(self.sample_save) self.current_value = 0 plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Distance [cm]', plot_list) layout_h1 = QHBoxLayout() layout_h1.addStretch() layout_h1.addWidget(self.distance_label) layout_h1.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.analog_label) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h1) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget) layout.addLayout(self.sample_layout)
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.js = bricklet_joystick.Joystick(self.uid) self.ipcon.add_device(self.js) self.version = '.'.join(map(str, self.js.get_version()[1])) self.qtcb_position.connect(self.cb_position) self.js.register_callback(self.js.CALLBACK_POSITION, self.qtcb_position.emit) self.qtcb_pressed.connect(self.cb_pressed) self.js.register_callback(self.js.CALLBACK_PRESSED, self.qtcb_pressed.emit) self.qtcb_released.connect(self.cb_released) self.js.register_callback(self.js.CALLBACK_RELEASED, self.qtcb_released.emit) self.joystick_frame = JoystickFrame(self) self.joystick_frame.setMinimumSize(220, 220) self.joystick_frame.setMaximumSize(220, 220) self.joystick_frame.set_position(0, 0) self.calibration_button = QPushButton('Calibrate (0, 0)') self.position_label = PositionLabel('Position: (0, 0)') self.calibration_button.pressed.connect(self.calibration_pressed) self.current_x = 0 self.current_y = 0 plot_list = [['X', Qt.darkGreen, self.get_current_x], ['Y', Qt.blue, self.get_current_y]] self.plot_widget = PlotWidget('Position', plot_list) layout_h1 = QHBoxLayout() layout_h1.addStretch() layout_h1.addWidget(self.position_label) layout_h1.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.joystick_frame) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h1) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget) layout.addWidget(self.calibration_button)
def __init__ (self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.tem = bricklet_temperature_ir.TemperatureIR(self.uid) self.ipcon.add_device(self.tem) self.version = '.'.join(map(str, self.tem.get_version()[1])) self.qtcb_ambient_temperature.connect(self.cb_ambient_temperature) self.tem.register_callback(self.tem.CALLBACK_AMBIENT_TEMPERATURE, self.qtcb_ambient_temperature.emit) self.qtcb_object_temperature.connect(self.cb_object_temperature) self.tem.register_callback(self.tem.CALLBACK_OBJECT_TEMPERATURE, self.qtcb_object_temperature.emit) self.ambient_label = AmbientLabel() self.object_label = ObjectLabel() self.emissivity_label = QLabel('Emissivity: ') self.emissivity_edit = QLineEdit() self.emissivity_button = QPushButton('Save') self.emissivity_layout = QHBoxLayout() self.emissivity_layout.addWidget(self.emissivity_label) self.emissivity_layout.addWidget(self.emissivity_edit) self.emissivity_layout.addWidget(self.emissivity_button) self.emissivity_button.pressed.connect(self.emissivity_pressed) self.current_ambient = 0 self.current_object = 0 plot_list = [['amb', Qt.blue, self.get_current_ambient], ['obj', Qt.red, self.get_current_object]] self.plot_widget = PlotWidget('Temperature [%cC]' % 0xB0, plot_list) layout_h1 = QHBoxLayout() layout_h1.addStretch() layout_h1.addWidget(self.ambient_label) layout_h1.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.object_label) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h1) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget) layout.addLayout(self.emissivity_layout)
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.cur = bricklet_current12.Current12(self.uid) self.ipcon.add_device(self.cur) self.version = '.'.join(map(str, self.cur.get_version()[1])) self.qtcb_current.connect(self.cb_current) self.cur.register_callback(self.cur.CALLBACK_CURRENT, self.qtcb_current.emit) self.qtcb_over.connect(self.cb_over) self.cur.register_callback(self.cur.CALLBACK_OVER_CURRENT, self.qtcb_over.emit) self.current_label = CurrentLabel('Current: ') self.over_label = QLabel('Over Current: No') self.calibrate_button = QPushButton('Calibrate') self.calibrate_button.pressed.connect(self.calibrate_pressed) self.current_value = 0 plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Current [mA]', plot_list) layout_h1 = QHBoxLayout() layout_h1.addStretch() layout_h1.addWidget(self.current_label) layout_h1.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.over_label) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h1) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget) layout.addWidget(self.calibrate_button)
def __init__(self, ipcon, uid): PluginBase.__init__(self, ipcon, uid) self.rp = bricklet_rotary_poti.RotaryPoti(self.uid) self.ipcon.add_device(self.rp) self.version = '.'.join(map(str, self.rp.get_version()[1])) self.qtcb_position.connect(self.cb_position) self.rp.register_callback(self.rp.CALLBACK_POSITION, self.qtcb_position.emit) self.position_knob = Qwt.QwtKnob(self) self.position_knob.setTotalAngle(300) self.position_knob.setScale(-150, 150, 30) self.position_knob.setRange(-150, 150) self.position_knob.setReadOnly(True) self.position_knob.setFocusPolicy(Qt.NoFocus) self.position_knob.setKnobWidth(40) self.position_label = PositionLabel('Position: ') self.current_value = 0 plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Position', plot_list) layout_h1 = QHBoxLayout() layout_h1.addStretch() layout_h1.addWidget(self.position_label) layout_h1.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.position_knob) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h1) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget)
def __init__(self): PlotWidget.__init__(self) self.sampleCount = 100 self.funcs = []
def __init__(self, model): ''' Args: Returns: Raises: ''' # initialize the super class super(MainWindow, self).__init__() self.model = model self.setWindowTitle("St. Luke's Circuit") self.setObjectName("MainWindow") self.setWindowIcon(qt4.QIcon(r"resources\bar_icon.png")) self.menuBar = self.menuBar() self.fileMenu = self.menuBar.addMenu("&File") self.editMenu = self.menuBar.addMenu("&Edit") self.viewMenu = self.menuBar.addMenu("&View") self.helpMenu = self.menuBar.addMenu("&Help") self.controlToolBar = self.addToolBar("Control") self.controlToolBar.setObjectName("ControlToolBar") self.statusBar = self.statusBar() self.statusBar.showMessage("Ready", 5000) #shown for 5 seconds self.splitter = qt4.QSplitter(qt4.Qt.Horizontal, self) #self.summaryTabLayout.setStretchFactor(self.splitter, 1) self.tableView = DataTableView() self.tableModel = DataTableModel(self, self.model) self.tableView.setModel(self.tableModel) self.splitter.addWidget(self.tableView) self.plotSplitter = qt4.QSplitter(qt4.Qt.Vertical, self.splitter) self.splitter.addWidget(self.plotSplitter) self.mplS1 = PlotWidget(self.plotSplitter) self.mplS1.setObjectName("mplS1") self.plotSplitter.addWidget(self.mplS1) self.mplS2 = PlotWidget(self.plotSplitter) self.mplS2.setObjectName("mplS2") self.plotSplitter.addWidget(self.mplS2) self.setCentralWidget(self.splitter) self.open1Action = self.action_factory( r"resources\fileopen1.png", "&Open", "Open session 1 circuit profile", self.open_circuit_profile1_slot, self.fileMenu, self.controlToolBar) self.open2Action = self.action_factory( r"resources\fileopen2.png", "&Open", "Open session 2 circuit profile", self.open_circuit_profile2_slot, self.fileMenu, self.controlToolBar) self.openGoalAction = self.action_factory( r"resources\fileopengoal.png", "&Open", "Open goal circuit profile", self.open_goal_slot, self.fileMenu, self.controlToolBar) self.saveAction = self.action_factory( r"resources\filesave.png", "&Save", "Save current circuit profile", self.save_circuit_profile_slot, self.fileMenu, self.controlToolBar) self.saveAsAction = self.action_factory( r"resources\filesaveas.png", "&SaveAs", "SaveAs current circuit profile", self.saveas_circuit_profile_slot, self.fileMenu, self.controlToolBar) self.patientViewAction = self.action_factory( r"resources\viewmag-.png", "&Patient", "Change view to patient perspective", self.patient_view_slot, self.viewMenu, self.controlToolBar, True, False) self.therapistViewAction = self.action_factory( r"resources\viewmag.png", "&Therapist", "Change view to therapist perspective", self.therapist_view_slot, self.viewMenu, self.controlToolBar, True, False) self.researcherViewAction = self.action_factory( r"resources\viewmag+.png", "&Researcher", "Change view to researcher perspective", self.researcher_view_slot, self.viewMenu, self.controlToolBar, True, True) self.helpAction = self.action_factory(r"resources\help.png", "&Help", "View the help guide", self.help_slot, self.fileMenu, self.controlToolBar) self.exitAction = self.action_factory(r"resources\exit.png", "&Exit", "Exit the application", self.close, self.fileMenu, self.controlToolBar)
class MainWindow(qt4.QMainWindow): ''' ''' controller = None model = None #*************************************__init__()************************************* def __init__(self, model): ''' Args: Returns: Raises: ''' # initialize the super class super(MainWindow, self).__init__() self.model = model self.setWindowTitle("St. Luke's Circuit") self.setObjectName("MainWindow") self.setWindowIcon(qt4.QIcon(r"resources\bar_icon.png")) self.menuBar = self.menuBar() self.fileMenu = self.menuBar.addMenu("&File") self.editMenu = self.menuBar.addMenu("&Edit") self.viewMenu = self.menuBar.addMenu("&View") self.helpMenu = self.menuBar.addMenu("&Help") self.controlToolBar = self.addToolBar("Control") self.controlToolBar.setObjectName("ControlToolBar") self.statusBar = self.statusBar() self.statusBar.showMessage("Ready", 5000) #shown for 5 seconds self.splitter = qt4.QSplitter(qt4.Qt.Horizontal, self) #self.summaryTabLayout.setStretchFactor(self.splitter, 1) self.tableView = DataTableView() self.tableModel = DataTableModel(self, self.model) self.tableView.setModel(self.tableModel) self.splitter.addWidget(self.tableView) self.plotSplitter = qt4.QSplitter(qt4.Qt.Vertical, self.splitter) self.splitter.addWidget(self.plotSplitter) self.mplS1 = PlotWidget(self.plotSplitter) self.mplS1.setObjectName("mplS1") self.plotSplitter.addWidget(self.mplS1) self.mplS2 = PlotWidget(self.plotSplitter) self.mplS2.setObjectName("mplS2") self.plotSplitter.addWidget(self.mplS2) self.setCentralWidget(self.splitter) self.open1Action = self.action_factory( r"resources\fileopen1.png", "&Open", "Open session 1 circuit profile", self.open_circuit_profile1_slot, self.fileMenu, self.controlToolBar) self.open2Action = self.action_factory( r"resources\fileopen2.png", "&Open", "Open session 2 circuit profile", self.open_circuit_profile2_slot, self.fileMenu, self.controlToolBar) self.openGoalAction = self.action_factory( r"resources\fileopengoal.png", "&Open", "Open goal circuit profile", self.open_goal_slot, self.fileMenu, self.controlToolBar) self.saveAction = self.action_factory( r"resources\filesave.png", "&Save", "Save current circuit profile", self.save_circuit_profile_slot, self.fileMenu, self.controlToolBar) self.saveAsAction = self.action_factory( r"resources\filesaveas.png", "&SaveAs", "SaveAs current circuit profile", self.saveas_circuit_profile_slot, self.fileMenu, self.controlToolBar) self.patientViewAction = self.action_factory( r"resources\viewmag-.png", "&Patient", "Change view to patient perspective", self.patient_view_slot, self.viewMenu, self.controlToolBar, True, False) self.therapistViewAction = self.action_factory( r"resources\viewmag.png", "&Therapist", "Change view to therapist perspective", self.therapist_view_slot, self.viewMenu, self.controlToolBar, True, False) self.researcherViewAction = self.action_factory( r"resources\viewmag+.png", "&Researcher", "Change view to researcher perspective", self.researcher_view_slot, self.viewMenu, self.controlToolBar, True, True) self.helpAction = self.action_factory(r"resources\help.png", "&Help", "View the help guide", self.help_slot, self.fileMenu, self.controlToolBar) self.exitAction = self.action_factory(r"resources\exit.png", "&Exit", "Exit the application", self.close, self.fileMenu, self.controlToolBar) #*************************************open_helper()************************************* def open_helper(self, identifier): ''' Args: Returns: Raises: ''' fd = qt4.QFileDialog(self, "Browse data file") fd.setDirectory(r"C:\Users\Gina\workspace\StLukesCircuit\data") fname = fd.getOpenFileName() if len(fname) > 0: self.model.load_circuit_profile(identifier, fname) #*************************************open_circuit_profile1_slot()************************************* def open_circuit_profile1_slot(self): ''' Args: Returns: Raises: ''' self.open_helper("S1") #*************************************open_circuit_profile2_slot()************************************* def open_circuit_profile2_slot(self): ''' Args: Returns: Raises: ''' self.open_helper("S2") #*************************************open_goal_slot()************************************* def open_goal_slot(self): ''' Args: Returns: Raises: ''' self.open_helper("Goal") #*************************************save_circuit_profile_slot()************************************* def save_circuit_profile_slot(self): ''' Args: Returns: Raises: ''' pass #*************************************saveas_circuit_profile_slot()************************************* def saveas_circuit_profile_slot(self): ''' Args: Returns: Raises: ''' pass #*************************************help_slot()************************************* def help_slot(self): ''' Args: Returns: Raises: ''' pass #*************************************uncheck_views()************************************* def uncheck_views(self): ''' Args: Returns: Raises: ''' self.therapistViewAction.setChecked(False) self.patientViewAction.setChecked(False) self.researcherViewAction.setChecked(False) #*************************************therapist_view_slot()************************************* def therapist_view_slot(self): ''' Args: Returns: Raises: ''' self.uncheck_views() self.therapistViewAction.setChecked(True) self.model.change_view("T") #*************************************patient_view_slot()************************************* def patient_view_slot(self): ''' Args: Returns: Raises: ''' self.uncheck_views() self.patientViewAction.setChecked(True) self.model.change_view("P") #*************************************researcher_view_slot()************************************* def researcher_view_slot(self): ''' Args: Returns: Raises: ''' self.uncheck_views() self.researcherViewAction.setChecked(True) self.model.change_view("R") #*************************************closeEvent()************************************* def closeEvent(self, event): ''' Args: Returns: Raises: ''' quit_msg = "Are you sure you want to exit the program?" reply = qt4.QMessageBox.question(self, "Exit", quit_msg, qt4.QMessageBox.Yes, qt4.QMessageBox.No) if reply == qt4.QMessageBox.Yes: event.accept() else: event.ignore() #*************************************action_factory()************************************* def action_factory(self, icon, name, tooltip, slot, menu, toolbar, checkable=False, checked=False): ''' Args: Returns: Raises: ''' action = qt4.QAction(qt4.QIcon(icon), name, self) action.setToolTip(tooltip) action.setStatusTip(tooltip) action.setCheckable(checkable) action.setChecked(checked) qt4.QObject.connect(action, qt4.SIGNAL("triggered()"), slot) menu.addAction(action) toolbar.addAction(action) return action
def __init__(self, model): ''' Args: Returns: Raises: ''' # initialize the super class super(MainWindow, self).__init__() self.model = model self.setWindowTitle("St. Luke's Circuit") self.setObjectName("MainWindow") self.setWindowIcon(qt4.QIcon(r"resources\bar_icon.png")) self.menuBar = self.menuBar() self.fileMenu = self.menuBar.addMenu("&File") self.editMenu = self.menuBar.addMenu("&Edit") self.viewMenu = self.menuBar.addMenu("&View") self.helpMenu = self.menuBar.addMenu("&Help") self.controlToolBar = self.addToolBar("Control") self.controlToolBar.setObjectName("ControlToolBar") self.statusBar = self.statusBar() self.statusBar.showMessage("Ready", 5000) #shown for 5 seconds self.splitter = qt4.QSplitter(qt4.Qt.Horizontal, self) #self.summaryTabLayout.setStretchFactor(self.splitter, 1) self.tableView = DataTableView() self.tableModel = DataTableModel(self, self.model) self.tableView.setModel(self.tableModel) self.splitter.addWidget(self.tableView) self.plotSplitter = qt4.QSplitter(qt4.Qt.Vertical, self.splitter) self.splitter.addWidget(self.plotSplitter) self.mplS1 = PlotWidget(self.plotSplitter) self.mplS1.setObjectName("mplS1") self.plotSplitter.addWidget(self.mplS1) self.mplS2 = PlotWidget(self.plotSplitter) self.mplS2.setObjectName("mplS2") self.plotSplitter.addWidget(self.mplS2) self.setCentralWidget(self.splitter) self.open1Action = self.action_factory(r"resources\fileopen1.png", "&Open", "Open session 1 circuit profile", self.open_circuit_profile1_slot, self.fileMenu, self.controlToolBar) self.open2Action = self.action_factory(r"resources\fileopen2.png", "&Open", "Open session 2 circuit profile", self.open_circuit_profile2_slot, self.fileMenu, self.controlToolBar) self.openGoalAction = self.action_factory(r"resources\fileopengoal.png", "&Open", "Open goal circuit profile", self.open_goal_slot, self.fileMenu, self.controlToolBar) self.saveAction = self.action_factory(r"resources\filesave.png", "&Save", "Save current circuit profile", self.save_circuit_profile_slot, self.fileMenu, self.controlToolBar) self.saveAsAction = self.action_factory(r"resources\filesaveas.png", "&SaveAs", "SaveAs current circuit profile", self.saveas_circuit_profile_slot, self.fileMenu, self.controlToolBar) self.patientViewAction = self.action_factory(r"resources\viewmag-.png", "&Patient", "Change view to patient perspective", self.patient_view_slot, self.viewMenu, self.controlToolBar, True, False) self.therapistViewAction = self.action_factory(r"resources\viewmag.png", "&Therapist", "Change view to therapist perspective", self.therapist_view_slot, self.viewMenu, self.controlToolBar, True, False) self.researcherViewAction = self.action_factory(r"resources\viewmag+.png", "&Researcher", "Change view to researcher perspective", self.researcher_view_slot, self.viewMenu, self.controlToolBar, True, True) self.helpAction = self.action_factory(r"resources\help.png", "&Help", "View the help guide", self.help_slot, self.fileMenu, self.controlToolBar) self.exitAction = self.action_factory(r"resources\exit.png", "&Exit", "Exit the application", self.close, self.fileMenu, self.controlToolBar)
class MainWindow(qt4.QMainWindow): ''' ''' controller = None model = None #*************************************__init__()************************************* def __init__(self, model): ''' Args: Returns: Raises: ''' # initialize the super class super(MainWindow, self).__init__() self.model = model self.setWindowTitle("St. Luke's Circuit") self.setObjectName("MainWindow") self.setWindowIcon(qt4.QIcon(r"resources\bar_icon.png")) self.menuBar = self.menuBar() self.fileMenu = self.menuBar.addMenu("&File") self.editMenu = self.menuBar.addMenu("&Edit") self.viewMenu = self.menuBar.addMenu("&View") self.helpMenu = self.menuBar.addMenu("&Help") self.controlToolBar = self.addToolBar("Control") self.controlToolBar.setObjectName("ControlToolBar") self.statusBar = self.statusBar() self.statusBar.showMessage("Ready", 5000) #shown for 5 seconds self.splitter = qt4.QSplitter(qt4.Qt.Horizontal, self) #self.summaryTabLayout.setStretchFactor(self.splitter, 1) self.tableView = DataTableView() self.tableModel = DataTableModel(self, self.model) self.tableView.setModel(self.tableModel) self.splitter.addWidget(self.tableView) self.plotSplitter = qt4.QSplitter(qt4.Qt.Vertical, self.splitter) self.splitter.addWidget(self.plotSplitter) self.mplS1 = PlotWidget(self.plotSplitter) self.mplS1.setObjectName("mplS1") self.plotSplitter.addWidget(self.mplS1) self.mplS2 = PlotWidget(self.plotSplitter) self.mplS2.setObjectName("mplS2") self.plotSplitter.addWidget(self.mplS2) self.setCentralWidget(self.splitter) self.open1Action = self.action_factory(r"resources\fileopen1.png", "&Open", "Open session 1 circuit profile", self.open_circuit_profile1_slot, self.fileMenu, self.controlToolBar) self.open2Action = self.action_factory(r"resources\fileopen2.png", "&Open", "Open session 2 circuit profile", self.open_circuit_profile2_slot, self.fileMenu, self.controlToolBar) self.openGoalAction = self.action_factory(r"resources\fileopengoal.png", "&Open", "Open goal circuit profile", self.open_goal_slot, self.fileMenu, self.controlToolBar) self.saveAction = self.action_factory(r"resources\filesave.png", "&Save", "Save current circuit profile", self.save_circuit_profile_slot, self.fileMenu, self.controlToolBar) self.saveAsAction = self.action_factory(r"resources\filesaveas.png", "&SaveAs", "SaveAs current circuit profile", self.saveas_circuit_profile_slot, self.fileMenu, self.controlToolBar) self.patientViewAction = self.action_factory(r"resources\viewmag-.png", "&Patient", "Change view to patient perspective", self.patient_view_slot, self.viewMenu, self.controlToolBar, True, False) self.therapistViewAction = self.action_factory(r"resources\viewmag.png", "&Therapist", "Change view to therapist perspective", self.therapist_view_slot, self.viewMenu, self.controlToolBar, True, False) self.researcherViewAction = self.action_factory(r"resources\viewmag+.png", "&Researcher", "Change view to researcher perspective", self.researcher_view_slot, self.viewMenu, self.controlToolBar, True, True) self.helpAction = self.action_factory(r"resources\help.png", "&Help", "View the help guide", self.help_slot, self.fileMenu, self.controlToolBar) self.exitAction = self.action_factory(r"resources\exit.png", "&Exit", "Exit the application", self.close, self.fileMenu, self.controlToolBar) #*************************************open_helper()************************************* def open_helper(self, identifier): ''' Args: Returns: Raises: ''' fd = qt4.QFileDialog(self, "Browse data file") fd.setDirectory(r"C:\Users\Gina\workspace\StLukesCircuit\data") fname = fd.getOpenFileName() if len(fname) > 0: self.model.load_circuit_profile(identifier, fname) #*************************************open_circuit_profile1_slot()************************************* def open_circuit_profile1_slot(self): ''' Args: Returns: Raises: ''' self.open_helper("S1") #*************************************open_circuit_profile2_slot()************************************* def open_circuit_profile2_slot(self): ''' Args: Returns: Raises: ''' self.open_helper("S2") #*************************************open_goal_slot()************************************* def open_goal_slot(self): ''' Args: Returns: Raises: ''' self.open_helper("Goal") #*************************************save_circuit_profile_slot()************************************* def save_circuit_profile_slot(self): ''' Args: Returns: Raises: ''' pass #*************************************saveas_circuit_profile_slot()************************************* def saveas_circuit_profile_slot(self): ''' Args: Returns: Raises: ''' pass #*************************************help_slot()************************************* def help_slot(self): ''' Args: Returns: Raises: ''' pass #*************************************uncheck_views()************************************* def uncheck_views(self): ''' Args: Returns: Raises: ''' self.therapistViewAction.setChecked(False) self.patientViewAction.setChecked(False) self.researcherViewAction.setChecked(False) #*************************************therapist_view_slot()************************************* def therapist_view_slot(self): ''' Args: Returns: Raises: ''' self.uncheck_views() self.therapistViewAction.setChecked(True) self.model.change_view("T") #*************************************patient_view_slot()************************************* def patient_view_slot(self): ''' Args: Returns: Raises: ''' self.uncheck_views() self.patientViewAction.setChecked(True) self.model.change_view("P") #*************************************researcher_view_slot()************************************* def researcher_view_slot(self): ''' Args: Returns: Raises: ''' self.uncheck_views() self.researcherViewAction.setChecked(True) self.model.change_view("R") #*************************************closeEvent()************************************* def closeEvent(self, event): ''' Args: Returns: Raises: ''' quit_msg = "Are you sure you want to exit the program?" reply = qt4.QMessageBox.question(self, "Exit", quit_msg, qt4.QMessageBox.Yes, qt4.QMessageBox.No) if reply == qt4.QMessageBox.Yes: event.accept() else: event.ignore() #*************************************action_factory()************************************* def action_factory(self, icon, name, tooltip, slot, menu, toolbar, checkable=False, checked=False): ''' Args: Returns: Raises: ''' action = qt4.QAction(qt4.QIcon(icon), name, self) action.setToolTip(tooltip) action.setStatusTip(tooltip) action.setCheckable(checkable) action.setChecked(checked) qt4.QObject.connect(action, qt4.SIGNAL("triggered()"), slot) menu.addAction(action) toolbar.addAction(action) return action
class PostProcMainWidget(QWidget): ''' this is the main GUI-Widget for the postprocessing Module it inherits from QWidget (Qt) contains three other widgets: BagSelectorWidget, InfoSelectorWidget, PlotWidget ''' def __init__(self): super(PostProcMainWidget, self).__init__() # init the GUI components: self.bagWidget = BagWidget(self) self.bagFiles = self.bagWidget.getBagFiles() self.plotWidget = PlotWidget(self.bagFiles, self) self.__addPlotBtn = QPushButton("Add new Graph") self.__delPlotBtn = QPushButton("Delete Graph") self.__qualityBtn = QPushButton("Compute Data Quality") # connect signals to slots: self.__addPlotBtn.clicked.connect(self.openNewGraphDialog) self.__delPlotBtn.clicked.connect(self.openDelGraphDialog) self.__qualityBtn.clicked.connect(self.openQualityDialog) # setup the layout: layout = QGridLayout() # (rowIndex, rowStretch) layout.setRowStretch( 0, 0) # controls behavior when changing the window size # (widget, fromRow, fromColumn, rowSpan, columnSpan) layout.addWidget(self.bagWidget, 0, 0, 1, 3) layout.setRowStretch(1, 0) layout.addWidget(self.__addPlotBtn, 1, 0, 1, 1) layout.addWidget(self.__delPlotBtn, 1, 1, 1, 1) layout.addWidget(self.__qualityBtn, 1, 2, 1, 1) layout.setRowStretch(2, 1) layout.addWidget(self.plotWidget, 2, 0, 1, 3) self.setLayout(layout) def openNewGraphDialog(self): ''' opens new dialog widget to determine the information required for a new plot ''' if self.plotWidget.lineCount >= MAX_LINES: message_module.showMessage( "Maximum number of graphs reached. Delete a graph before adding a new one." ) return self.bagFiles = self.bagWidget.getBagFiles() plotDialog = PlotDialogWidget(self.bagFiles, self) plotDialog.newPlotData.connect(self.plotWidget.plot) plotDialog.exec_() def openDelGraphDialog(self): ''' opens a new dialog to delete one or several graphs from the figure ''' linesList = self.plotWidget.getLines() delPlotDialog = DelPlotDialog(linesList, self) delPlotDialog.deletePressed.connect(self.plotWidget.deleteGraph) delPlotDialog.exec_() def openQualityDialog(self): ''' opens a new dialog that shows the data quality ''' self.bagFiles = self.bagWidget.getBagFiles() if self.bagFiles[0] == "" or self.bagFiles[1] == "": message_module.showMessage( "Bag file missing! Please import bag file in the main interface." ) return qualityDialog = QualityDialog(self.bagFiles, self) qualityDialog.exec_()
class VagaWindow(QtWidgets.QMainWindow): # klasa nasljeduje QMainWindow def __init__(self): # inicijalizacija klase super().__init__() # ******* Define class atributes ****** # self.selected_port = None self.data = MeasurementData( ) # apsolutno svi podaci, polje dictionaryja self.threadpool = QtCore.QThreadPool() self.initUI() def initUI(self): # sve sto zelimo u prozoru # ******* Create central Widget ******** # self.centralwidget = QtWidgets.QWidget(self) self.centralwidget.setObjectName("centralwidget") # ******* Create widgets ******* # self.PortWidget = PortWidget(self) self.ControlWidget = ControlWidget(self) self.PlotWidget = PlotWidget(self) self.RectangleWidget = RectangleWidget(self) self.StatisticsWidget = StatisticsWidget(self) # ****** Create central layout and add widgets to it ****** # centralLayout = QtWidgets.QGridLayout() centralLayout.setColumnStretch(0, 1) centralLayout.setColumnStretch(1, 3) centralLayout.setColumnStretch(2, 2) centralLayout.setRowStretch(0, 1) centralLayout.setRowStretch(1, 5) #todo vratit sa 5 na 2 centralLayout.addWidget(self.PortWidget, 0, 0) centralLayout.addWidget(self.ControlWidget, 0, 1) centralLayout.addWidget(self.PlotWidget, 1, 1) centralLayout.addWidget(self.RectangleWidget, 1, 0) centralLayout.addWidget(self.StatisticsWidget, 1, 2) # *********** Window properties ************ # self.centralwidget.setLayout(centralLayout) self.setCentralWidget(self.centralwidget) self.setGeometry(200, 100, 900, 500) #todo maybe vratit sirinu na 1000 self.setWindowTitle("Biomehanička vaga") def measureData(self): self.worker = Worker(self.PortWidget.ser) self.worker.signals.result.connect(self.print_result) self.worker.signals.finished.connect(self.do_after_finish_measure) self.threadpool.start(self.worker) def print_result(self, res): self.data.measurement.append(res) self.PlotWidget.animate(self.data.measurement[-1]["CycleID"]) print(res) def do_after_finish_measure(self): print("Gotovo cijelo mjerenje od 30 sek") self.ControlWidget.startButton.setEnabled(True) self.ControlWidget.stopButton.setDisabled(True) self.ControlWidget.storeButton.setEnabled(True)
def __init__(self): PlotWidget.__init__(self) self.sampleCount=100; self.funcs = []