Example #1
0
    def __init__(self, channel_inputs_layout, ver_set_layout, zmq_rpc, plot,
                 GUI_name, GUI_channel_idx, update_triggers, GUI):
        self.__adc_label = QLabel("")
        self.__adc_label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.__channel_label = QLabel("")
        self.__channel_label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.__menu = ChannelsMenu(self, GUI_channel_idx, GUI)
        self.GUI_channel_idx = GUI_channel_idx
        self.__chan_in_layout = ChannelInputsLayout(self.__menu,
                                                    self.__adc_label,
                                                    self.__channel_label)
        channel_inputs_layout.addLayout(self.__chan_in_layout)

        self.__chan_set_frame = QFrame()
        self.__chan_set_layout = ChannelSettingsLayout(GUI_channel_idx)
        self.__chan_set_frame.setLayout(self.__chan_set_layout)
        color = Colors().get_greyed_color(GUI_channel_idx)
        self.__chan_set_frame.setStyleSheet("background-color: rgb" + color +
                                            ";")
        ver_set_layout.addWidget(self.__chan_set_frame)

        self.__plot = plot
        self.__GUI_name = GUI_name
        self.__zmq_rpc = zmq_rpc
        self.__GUI = GUI
        """updates the list of channels for the trigger"""
        self.update_triggers = update_triggers
        self.__range_menu = None
        self.__termination_menu = None
        self.__offset_box = None
        self.ADC_channel_idx = None
        self.unique_ADC_name = None
        self.__set_empty_channel()
Example #2
0
    def __init__(self, idx, unique_ADC_name, dial_name, layout='horizontal'):
        super().__init__()
        self.idx = idx
        self.unique_ADC_name = unique_ADC_name
        if layout == "horizontal":
            self.layout = QtGui.QHBoxLayout()
        else:
            self.layout = QtGui.QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(2)

        self.frame = QFrame()
        self.frame.setLayout(self.layout)
        #self.frame.setStyleSheet("border:0px solid rgb(200, 200, 200); ")

        self.dial= QDial()
        self.label = QLabel(dial_name)
        self.box = QSpinBox()

        self.label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)

        self.layout.addWidget(self.label)
        self.layout.addWidget(self.dial)
        self.layout.addWidget(self.box)

        self.dial.valueChanged.connect(self.value_change_dial)
        self.box.valueChanged.connect(self.value_change_box)
        """If unique_ADC_name is None it means that the certain channel
        is no enabled therefore the widget is disabled"""
        if(unique_ADC_name is None):
            self.frame.setEnabled(False)
Example #3
0
    def initUI(self):
        cw = QWidget()
        self.setCentralWidget(cw)
        grid = QGridLayout()
        grid.setSpacing(15)

        # status bar
        self.statusBar().showMessage('Ready')

        font_label = QFont()
        font_label.setBold(True)
        ################ dicom reader
        rstart = 0
        text_dcm = QLabel('DICOM reader')
        text_dcm.setFont(font_label)
        self.text_dcm_dir = QLabel('DICOM dir:')
        self.text_dcm_data = QLabel('DICOM data:')
        self.text_dcm_out = QLabel('output file:')
        grid.addWidget(text_dcm, rstart + 0, 1, 1, 4)
        grid.addWidget(self.text_dcm_dir, rstart + 1, 1, 1, 4)
        grid.addWidget(self.text_dcm_data, rstart + 2, 1, 1, 4)
        grid.addWidget(self.text_dcm_out, rstart + 3, 1, 1, 4)
        btn_dcmdir = QPushButton("Load DICOM", self)
        btn_dcmdir.clicked.connect(self.loadDcmDir)
        btn_dcmred = QPushButton("Organ Segmentation", self)
        btn_dcmred.clicked.connect(self.organSegmentation)
        btn_dcmcrop = QPushButton("Crop", self)
        btn_dcmcrop.clicked.connect(self.cropDcm)
        btn_dcmsave = QPushButton("Save DCM", self)
        btn_dcmsave.clicked.connect(self.saveDcm)
        grid.addWidget(btn_dcmdir, rstart + 4, 1)
        grid.addWidget(btn_dcmred, rstart + 4, 2)
        grid.addWidget(btn_dcmcrop, rstart + 4, 3)
        grid.addWidget(btn_dcmsave, rstart + 4, 4)

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        grid.addWidget(hr, rstart + 5, 0, 1, 6)

        # quit
        btn_quit = QPushButton("Quit", self)
        btn_quit.clicked.connect(self.quit)
        grid.addWidget(btn_quit, 24, 2, 1, 2)

        cw.setLayout(grid)
        self.setWindowTitle('liver-surgery')
        self.show()
    def __init__(self, scheme, parent):
        super(EditorSchemeDesigner, self).__init__(parent, Qt.Dialog)
        self.original_style = copy.copy(resources.CUSTOM_SCHEME)
        self._avoid_on_loading, self.saved, self._components = True, False, {}
        self.setWindowTitle(translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER)
        self.setMinimumSize(450, 480)
        self.setMaximumSize(500, 900)
        self.resize(450, 600)

        # all layouts and groupboxes
        group0 = QGroupBox(translations.TR_PROJECT_NAME)  # scheme filename
        group1 = QGroupBox(translations.TR_PROJECT_PROPERTIES)  # properties
        group2 = QGroupBox(translations.TR_PREVIEW)  # quick preview thingy
        group0_hbox, group1_vbox = QHBoxLayout(group0), QVBoxLayout(group1)
        this_dialog_vbox, group2_vbox = QVBoxLayout(self), QVBoxLayout(group2)
        self._grid, scrollArea, frame = QGridLayout(), QScrollArea(), QFrame()

        # widgets
        self.line_name, btnSave = QLineEdit(), QPushButton(
            translations.TR_SAVE)
        self.line_name.setPlaceholderText(getuser().capitalize() + "s_scheme")
        group0_hbox.addWidget(self.line_name)
        group0_hbox.addWidget(btnSave)
        self.connect(btnSave, SIGNAL("clicked()"), self.save_scheme)
        _demo = "<center>" + ascii_letters  # demo text for preview
        self.preview_label1, self.preview_label2 = QLabel(_demo), QLabel(_demo)
        group2_vbox.addWidget(self.preview_label1)
        group2_vbox.addWidget(self.preview_label2)

        # rows titles
        self._grid.addWidget(QLabel("<b>" + translations.TR_PROJECT_NAME), 0,
                             0)
        self._grid.addWidget(QLabel("<b>" + translations.TR_CODE), 0, 1)
        self._grid.addWidget(
            QLabel("<b>" + translations.TR_EDITOR_SCHEME_PICK_COLOR), 0, 2)

        # fill rows
        for key in sorted(tuple(resources.COLOR_SCHEME.keys())):
            self.add_item(key, scheme)
        self.preview_label1.setStyleSheet('background:transparent')
        self.preview_label2.setStyleSheet('color:     transparent')

        # fill the scroll area
        frame.setLayout(self._grid)
        scrollArea.setWidget(frame)
        group1_vbox.addWidget(scrollArea)

        # put groups on the dialog
        this_dialog_vbox.addWidget(group1)
        this_dialog_vbox.addWidget(group2)
        this_dialog_vbox.addWidget(group0)
        self._avoid_on_loading = self._modified = False
Example #5
0
class ChannelClosure:
    def __init__(self, channel_inputs_layout, ver_set_layout, zmq_rpc, plot,
                 GUI_name, GUI_channel_idx, update_triggers, GUI):
        self.__adc_label = QLabel("")
        self.__adc_label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.__channel_label = QLabel("")
        self.__channel_label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.__menu = ChannelsMenu(self, GUI_channel_idx, GUI)
        self.GUI_channel_idx = GUI_channel_idx
        self.__chan_in_layout = ChannelInputsLayout(self.__menu,
                                                    self.__adc_label,
                                                    self.__channel_label)
        channel_inputs_layout.addLayout(self.__chan_in_layout)

        self.__chan_set_frame = QFrame()
        self.__chan_set_layout = ChannelSettingsLayout(GUI_channel_idx)
        self.__chan_set_frame.setLayout(self.__chan_set_layout)
        color = Colors().get_greyed_color(GUI_channel_idx)
        self.__chan_set_frame.setStyleSheet("background-color: rgb" + color +
                                            ";")
        ver_set_layout.addWidget(self.__chan_set_frame)

        self.__plot = plot
        self.__GUI_name = GUI_name
        self.__zmq_rpc = zmq_rpc
        self.__GUI = GUI
        """updates the list of channels for the trigger"""
        self.update_triggers = update_triggers
        self.__range_menu = None
        self.__termination_menu = None
        self.__offset_box = None
        self.ADC_channel_idx = None
        self.unique_ADC_name = None
        self.__set_empty_channel()

    def register_ADC(self, name, number_of_channels):
        self.__menu.register_ADC(name, number_of_channels)

    def unregister_ADC(self, name, remote=False):
        self.__menu.unregister_ADC(name)
        if self.channel_exists():
            if (self.unique_ADC_name == name):
                self.remove_channel(remote)

    def set_ADC_available(self, unique_ADC_name):
        self.__menu.set_ADC_available(unique_ADC_name)

    def set_ADC_unavailable(self, unique_ADC_name):
        self.__menu.set_ADC_unavailable(unique_ADC_name)

    def __set_empty_channel(self):
        self.ADC_channel_idx = None
        self.unique_ADC_name = None
        self.__set_widgets()

    def set_channel(self, unique_ADC_name, ADC_channel_idx):
        self.__remove_widgets()
        self.ADC_channel_idx = ADC_channel_idx
        self.unique_ADC_name = unique_ADC_name
        self.__set_widgets()
        self.update_triggers()
        self.__plot.add_channel(self.GUI_channel_idx)
        rpc = self.__zmq_rpc
        rpc.send_RPC('add_channel', self.GUI_channel_idx, self.unique_ADC_name,
                     self.ADC_channel_idx, self.__GUI_name)
        self.__GUI.update_GUI_params()
        self.__set_labels()

    def remove_channel(self, remote=False):
        if self.channel_exists():
            trigger = self.__GUI.triggers[0]
            if (trigger.ADC_idx == self.ADC_channel_idx
                    and trigger.unique_ADC_name == self.unique_ADC_name):
                trigger.remove_trigger(remote)
            self.__plot.remove_channel(self.GUI_channel_idx)
            if not remote:
                self.__zmq_rpc.send_RPC('remove_channel', self.GUI_channel_idx,
                                        self.__GUI_name)
            self.__remove_labels()
            self.ADC_channel_idx = None
            self.unique_ADC_name = None
        self.__remove_widgets()
        self.__set_empty_channel()
        self.update_triggers()

    def channel_exists(self):
        return self.unique_ADC_name is not None

    def set_channel_params(self, range, termination, offset):
        self.__range_menu.set_value(range)
        self.__termination_menu.set_value(termination)
        self.__offset_box.set_value(offset)

    def __set_widgets(self):
        self.__range_menu = ChannelRange(self.ADC_channel_idx,
                                         self.unique_ADC_name, self.__zmq_rpc,
                                         self.__GUI)
        self.__termination_menu = ChannelTermination(self.ADC_channel_idx,
                                                     self.unique_ADC_name,
                                                     self.__zmq_rpc,
                                                     self.__GUI)
        self.__offset_box = ChannelOffset(self.ADC_channel_idx,
                                          self.unique_ADC_name, self.__zmq_rpc,
                                          self.__GUI)

        self.__chan_set_layout.addWidget(self.__range_menu)
        self.__chan_set_layout.addWidget(self.__termination_menu)
        self.__chan_set_layout.addWidget(self.__offset_box.frame)

    def __set_labels(self):
        display_ADC_name = self.unique_ADC_name.replace('._tcp.local.', '')
        self.__adc_label.setText(display_ADC_name)
        self.__channel_label.setText('Channel ' + str(self.ADC_channel_idx))

    def __remove_widgets(self):
        self.__range_menu.deleteLater()
        self.__termination_menu.deleteLater()
        self.__offset_box.frame.deleteLater()

    def __remove_labels(self):
        self.__adc_label.setText('')
        self.__channel_label.setText('')
Example #6
0
    def createOptionsGroup(self):
        #1. Create a widget (here: QGroupBox)
        self.groupBox = QGroupBox()
        self.groupBox.setAlignment(4)

        #2. Create a couple of elements
        self.save_to_database = QtGui.QPushButton()
        self.save_to_database.setText("Save to database")

        self.line = QFrame()
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)

        #Mother or child select

        mother_child = QtGui.QHBoxLayout()
        self.mother_btn = QRadioButton("Mother")
        self.mother_btn.setChecked(True)
        self.mother = True
        mother_child.addWidget(self.mother_btn)
        self.mother_btn.toggled.connect(lambda:self.set_mother(self.mother_btn))


        self.child_btn = QRadioButton("Child")
        self.child_btn.setChecked(False)
        self.child = False
        mother_child.addWidget(self.child_btn)
        self.child_btn.toggled.connect(lambda:self.set_child(self.child_btn))

        #Coordinates display
        self.coordinates1 = QLineEdit()
        self.coordinates1.setFixedWidth(40)
        self.coordinates2 = QLineEdit()
        self.coordinates2.setFixedWidth(40)
        self.coordinates3 = QLineEdit()
        self.coordinates3.setFixedWidth(40)
        self.coordinates4 = QLineEdit()
        self.coordinates4.setFixedWidth(40)

        l1_str = "Dyad: "+str(self.video.get_dyad())+ "\t\t Camera: " + str(self.video.get_camera())
        self.l1 = QLabel(l1_str)
        self.l2 = QLabel("Comment (optional)")
        self.l3 = QLabel("Coordinates")

        self.comment = QLineEdit()

        #3. Add them to a QVBoxLayout (Vertical)
        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(self.coordinates1)
        hbox.addWidget(self.coordinates2)
        hbox.addWidget(self.coordinates3)
        hbox.addWidget(self.coordinates4)

        vbox = QVBoxLayout()
        vbox.addWidget(self.l1)
        vbox.addWidget(self.line)
        vbox.addWidget(self.l2)
        vbox.addWidget(self.comment)
        vbox.addLayout(mother_child)
        vbox.addWidget(self.l3)
        vbox.addLayout(hbox)
        vbox.addWidget(self.save_to_database)



        vbox.addStretch(1)#Add empty QSpacerItem that pushes the buttons upwards

        #4. Add layout to widget
        self.groupBox.setLayout(vbox)

        return self.groupBox
Example #7
0
class MotionWindowSelector(QtGui.QMainWindow):
    def __init__(self, video, parent=None):
        super(MotionWindowSelector, self).__init__(parent)
        self.video = video
        self.setWindowTitle(QtGui.QApplication.translate("Motion Selector", "Motion Selector", None))

        # 1. Create Widget
        self.centralwidget = QtGui.QWidget(self)
        self.setFixedSize(1200, 600)

        #2. Create a couple of elements
        self.box = SelectBoxOverlay()

        self.video_plot = VideoPlot(self.video, centered=False)
        self.video_plot.setFixedSize(960,540)#Hardcoded: Width and height are half of 16x9 HD videos

        self.video.frame.connect(self.video_plot.update)
        self.video_plot.installEventFilter(self.box)

        #3.Create Layout
        self.horizontalLayout = QtGui.QHBoxLayout(self.centralwidget)

        self.horizontalLayout.addWidget(self.video_plot)#ADD VIDEO HERE
        self.horizontalLayout.addWidget(self.createOptionsGroup())

        #4. Make remaining connections
        self.box.coordinates.connect(self.say)


        self.setLayout(self.horizontalLayout)#First add to layout THEN setLayout THEN setCentralWidget that was used to create layout
        self.setCentralWidget(self.centralwidget)#Essential


    def say(self, coordinates):#Qrect
        self.coordinates1.setText(str(coordinates.top()*2))
        self.coordinates2.setText(str(coordinates.left()*2))
        self.coordinates3.setText(str(coordinates.bottom()*2))
        self.coordinates4.setText(str(coordinates.right()*2))
        #self.centralwidget.setFixedSize(self.centralwidget.size())

    def set_mother(self,b):
        if b.isChecked() == True:
            self.mother = True
            self.child = False
        else:
            self.mother = False
            self.child = True

    def set_child(self,b):
        if b.isChecked() == True:
            self.mother = False
            self.child = True
        else:
            self.mother = True
            self.child = False

    def createOptionsGroup(self):
        #1. Create a widget (here: QGroupBox)
        self.groupBox = QGroupBox()
        self.groupBox.setAlignment(4)

        #2. Create a couple of elements
        self.save_to_database = QtGui.QPushButton()
        self.save_to_database.setText("Save to database")

        self.line = QFrame()
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)

        #Mother or child select

        mother_child = QtGui.QHBoxLayout()
        self.mother_btn = QRadioButton("Mother")
        self.mother_btn.setChecked(True)
        self.mother = True
        mother_child.addWidget(self.mother_btn)
        self.mother_btn.toggled.connect(lambda:self.set_mother(self.mother_btn))


        self.child_btn = QRadioButton("Child")
        self.child_btn.setChecked(False)
        self.child = False
        mother_child.addWidget(self.child_btn)
        self.child_btn.toggled.connect(lambda:self.set_child(self.child_btn))

        #Coordinates display
        self.coordinates1 = QLineEdit()
        self.coordinates1.setFixedWidth(40)
        self.coordinates2 = QLineEdit()
        self.coordinates2.setFixedWidth(40)
        self.coordinates3 = QLineEdit()
        self.coordinates3.setFixedWidth(40)
        self.coordinates4 = QLineEdit()
        self.coordinates4.setFixedWidth(40)

        l1_str = "Dyad: "+str(self.video.get_dyad())+ "\t\t Camera: " + str(self.video.get_camera())
        self.l1 = QLabel(l1_str)
        self.l2 = QLabel("Comment (optional)")
        self.l3 = QLabel("Coordinates")

        self.comment = QLineEdit()

        #3. Add them to a QVBoxLayout (Vertical)
        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(self.coordinates1)
        hbox.addWidget(self.coordinates2)
        hbox.addWidget(self.coordinates3)
        hbox.addWidget(self.coordinates4)

        vbox = QVBoxLayout()
        vbox.addWidget(self.l1)
        vbox.addWidget(self.line)
        vbox.addWidget(self.l2)
        vbox.addWidget(self.comment)
        vbox.addLayout(mother_child)
        vbox.addWidget(self.l3)
        vbox.addLayout(hbox)
        vbox.addWidget(self.save_to_database)



        vbox.addStretch(1)#Add empty QSpacerItem that pushes the buttons upwards

        #4. Add layout to widget
        self.groupBox.setLayout(vbox)

        return self.groupBox