def __init__(self):
        super().__init__()
        self.BASE_DIR = "D:\\thesis\\ConvNet\\MyNet\\temp\\"
        data = self.get_information()
        self.prediction_type = "talk"
        self.sampling_rate = int(data["sampling_rate"])
        self.sample_width = int(data["sample_width"])
        self.blocksize = int(data["blocksize"])
        self.channels = int(data["channels"])
        self.amplitude = int(data["amplitude"])
        self.record_duration = int(data["record_duration"])
        self.audio_plotter = AudioPlotter(self.blocksize, self.sampling_rate,
                                          self)
        self.audio_streamer = AudioStreamer(
            self.audio_plotter, self.blocksize, self.sampling_rate,
            self.channels, self.record_duration, self.set_duration,
            self.prediction_type, self.update_prediction,
            self.update_processing)
        #self.audio_processor = AudioProcessor(self.audio_streamer, self, self.sampling_rate, self.channels)

        self.audio_streamer_thread = None
        #self.audio_processor_thread = None
        self.audio_plotter_thread = None
        self.WINDOW_TOP = 100
        self.WINDOW_LEFT = 100
        self.WINDOW_WIDTH = GetSystemMetrics(0) - 100
        self.WINDOW_HEIGHT = GetSystemMetrics(1) - 100
        self.TITLE = "Audio Signal Processing"
        self.fig = plt.figure()
        self.ax = []
        self.ax.append(self.fig.add_subplot(4, 1, 1))
        self.ax.append(self.fig.add_subplot(4, 1, 2))
        self.ax.append(self.fig.add_subplot(4, 1, 3))
        self.ax.append(self.fig.add_subplot(4, 1, 4))
        self.canvas = FigureCanvas(self.fig)
        self.toolbar = NavigationToolbar(self.canvas, self)

        self.root_layout = None

        self.prediction_type_label = QLabel('Type:', self)
        self.prediction_type_data = QLabel(self.prediction_type.upper(), self)
        self.prediction_processing_label = QLabel("Inactive", self)
        self.prediction_output_type = QLabel('Last Predicted:', self)
        self.prediction_output_data = QLabel('N/A', self)
        self.start_stream_button = QPushButton('Start Streaming', self)
        self.stop_stream_button = QPushButton('Stop Streaming', self)
        self.mute_audio_button = QPushButton('Mute Audio', self)
        self.record_dir_input = QLineEdit(self)
        self.record_dir_input.setText('other')
        #self.record_button = QPushButton('Start/Stop Record',self)
        #self.save_recorded_button = QPushButton('Save Recorded', self)
        self.amplitude_slider = QSlider()
        self.amplitude_slider.setMinimum(0)
        self.amplitude_slider.setMaximum(10)
        self.amplitude_slider.setTickInterval(1)
        self.amplitude_slider.setValue(1)

        self.recorded_duration_label = QLabel(
            'Last Recorded Duration: 0 '.upper() + 'seconds', self)
        self.recorded_duration_total_label = QLabel(
            'Total Recorded Duration: 0 '.upper() + 'seconds', self)
        self.audio_info_labels = []
        for key in data:
            self.audio_info_labels.append(
                QLabel(
                    str(key).upper().replace('_', ' ') + ": " +
                    str(data[key])))
        self.root_layout = QVBoxLayout()
        self.root_row_buttons_layout = QHBoxLayout()
        self.root_row_info_layout = QHBoxLayout()
        self.root_row_plot_layout = QHBoxLayout()
        self.root_row_classification_layout = QHBoxLayout()
        self.root_row_plot = QGroupBox("Plot Tab")
        self.root_row_plot.setLayout(self.root_row_plot_layout)
        self.root_row_data_scroller = QScrollArea()

        self.root_row_data = QWidget(self.root_row_data_scroller)
        self.root_row_data_layout = QVBoxLayout()
        self.root_row_data.setLayout(self.root_row_data_layout)
        self.root_row_info = QGroupBox("Information")
        self.root_row_info.setLayout(self.root_row_info_layout)
        self.root_row_buttons = QGroupBox('Buttons')
        self.root_row_buttons.setLayout(self.root_row_buttons_layout)
        self.root_row_classification = QGroupBox("Classification")
        self.root_row_classification.setLayout(
            self.root_row_classification_layout)
        self.initWindow()
Beispiel #2
0
    def initUI(self):

        # SET THE GEOMETRY

        mainWindow = QtGui.QVBoxLayout()
        mainWindow.setSpacing(15)

        fileBox = QtGui.QHBoxLayout()
        spaceBox1 = QtGui.QHBoxLayout()
        rawDataBox = QtGui.QHBoxLayout()

        mainWindow.addLayout(fileBox)
        mainWindow.addLayout(spaceBox1)
        mainWindow.addLayout(rawDataBox)

        Col1 = QtGui.QGridLayout()
        Col2 = QtGui.QHBoxLayout()
        Col3 = QtGui.QVBoxLayout()

        rawDataBox.addLayout(Col1)
        rawDataBox.addLayout(Col2)
        rawDataBox.addLayout(Col3)

        self.setLayout(mainWindow)

        # DEFINE ALL WIDGETS AND BUTTONS

        loadBtn = QtGui.QPushButton('Load DataSet')
        saveBtn = QtGui.QPushButton('Save data (F12)')

        tpLbl = QtGui.QLabel('Relative Tp:')
        slLbl = QtGui.QLabel('Slice:')
        fNameLbl = QtGui.QLabel('File name:')

        self.tp = QtGui.QSpinBox(self)
        self.tp.setValue(0)
        self.tp.setMaximum(100000)

        self.sl = QtGui.QSpinBox(self)
        self.sl.setValue(0)
        self.sl.setMaximum(100000)

        self.fName = QtGui.QLabel('')

        self._488nmBtn = QtGui.QRadioButton('488nm')
        self._561nmBtn = QtGui.QRadioButton('561nm')
        self.CoolLEDBtn = QtGui.QRadioButton('CoolLED')

        self.sld1 = QtGui.QSlider(QtCore.Qt.Vertical, self)
        self.sld1.setMaximum(2**16 - 1)
        self.sld1.setValue(0)
        self.sld2 = QtGui.QSlider(QtCore.Qt.Vertical, self)
        self.sld2.setMaximum(2**16)
        self.sld2.setValue(2**16 - 1)

        self.fig1 = Figure((8.0, 8.0), dpi=100)
        self.fig1.subplots_adjust(left=0., right=1., top=1., bottom=0.)
        self.ax1 = self.fig1.add_subplot(111)
        self.canvas1 = FigureCanvas(self.fig1)
        self.canvas1.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.canvas1.setFocus()
        self.canvas1.setFixedSize(QtCore.QSize(600, 600))
        self.canvas1.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)

        self.cellTbl = QtGui.QTableWidget()

        self.fig2 = Figure((4.0, 4.0), dpi=100)
        self.fig2.subplots_adjust(left=0., right=1., top=1., bottom=0.)
        self.ax2 = self.fig2.add_subplot(111)
        self.canvas2 = FigureCanvas(self.fig2)
        self.canvas2.setFixedSize(QtCore.QSize(300, 300))
        self.canvas2.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)

        # self.cellNamesBox=QtGui.QMenu(self.canvas1)
        # actn = []
        # for cname in self.cellNames:
        #     actn.append( QtGui.QAction(cname, self.cellNamesBox) )
        #     self.cellNamesBox.addAction(actn[-1])
        #     actn[-1].triggered.connect( lambda item = cname : self.actionFunct(cname) )

        self.cellNamesBox = QtGui.QMenu(self.canvas1)

        ### define all actions (can be done better!!!)
        actn1p = QtGui.QAction('1.p', self.cellNamesBox)
        self.cellNamesBox.addAction(actn1p)
        actn1p.triggered.connect(lambda item='1.p': self.actionFunct1p('1.p'))

        actn1pp = QtGui.QAction('1.pp', self.cellNamesBox)
        self.cellNamesBox.addAction(actn1pp)
        actn1pp.triggered.connect(
            lambda item='1.pp': self.actionFunct1pp('1.pp'))

        actn1ppp = QtGui.QAction('1.ppp', self.cellNamesBox)
        self.cellNamesBox.addAction(actn1ppp)
        actn1ppp.triggered.connect(
            lambda item='1.ppp': self.actionFunct1ppp('1.ppp'))

        actn1ppa = QtGui.QAction('1.ppa', self.cellNamesBox)
        self.cellNamesBox.addAction(actn1ppa)
        actn1ppa.triggered.connect(
            lambda item='1.ppa': self.actionFunct1ppa('1.ppa'))

        actn4a = QtGui.QAction('4.a', self.cellNamesBox)
        self.cellNamesBox.addAction(actn4a)
        actn4a.triggered.connect(lambda item='4.a': self.actionFunct4a('4.a'))

        actn4aa = QtGui.QAction('4.aa', self.cellNamesBox)
        self.cellNamesBox.addAction(actn4aa)
        actn4aa.triggered.connect(
            lambda item='4.aa': self.actionFunct4aa('4.aa'))

        actn4aaa = QtGui.QAction('4.aaa', self.cellNamesBox)
        self.cellNamesBox.addAction(actn4aaa)
        actn4aaa.triggered.connect(
            lambda item='4.aaa': self.actionFunct4aaa('4.aaa'))

        actn4aap = QtGui.QAction('4.aap', self.cellNamesBox)
        self.cellNamesBox.addAction(actn4aap)
        actn4aap.triggered.connect(
            lambda item='4.aap': self.actionFunct4aap('4.aap'))

        actnb1 = QtGui.QAction('b_1', self.cellNamesBox)
        self.cellNamesBox.addAction(actnb1)
        actnb1.triggered.connect(lambda item='b_1': self.actionFunctb1('b_1'))

        actnb4 = QtGui.QAction('b_4', self.cellNamesBox)
        self.cellNamesBox.addAction(actnb4)
        actnb4.triggered.connect(lambda item='b_4': self.actionFunctb4('b_4'))
        ### END OF THE UGLY PART :)

        self.cellNamesBox.installEventFilter(self)
        self.canvas1.installEventFilter(self)
        self.cellNamesBox.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.cellNamesBox.connect(
            self.cellNamesBox,
            QtCore.SIGNAL("customContextMenuRequested(QPoint)"),
            self.leftClicked)

        # PLACE ALL THE WIDGET ACCORDING TO THE GRIDS

        fileBox.addWidget(loadBtn)
        fileBox.addWidget(saveBtn)

        spaceBox1.addWidget(self.HLine())

        Col1.addWidget(tpLbl, 0, 0)  #, 1, 1, Qt.AlignTop)
        Col1.addWidget(self.tp, 0, 1)  #, 1, 1, Qt.AlignTop)
        Col1.addWidget(slLbl, 1, 0)  #, 1, 1, Qt.AlignTop)
        Col1.addWidget(self.sl, 1, 1)  #, 1, 1, Qt.AlignTop)
        Col1.addWidget(fNameLbl, 2, 0)
        Col1.addWidget(self.fName, 2, 1)
        Col1.addWidget(self._488nmBtn, 3, 0)
        Col1.addWidget(self._561nmBtn, 4, 0)
        Col1.addWidget(self.CoolLEDBtn, 5, 0)

        Col2.addWidget(self.sld1)
        Col2.addWidget(self.sld2)
        Col2.addWidget(self.canvas1)

        # Col3.addWidget(self.cellTbl)
        # Col3.addWidget(self.cellNamesBox)
        Col3.addWidget(self.canvas2)

        self.setFocus()

        self.show()

        # BIND BUTTONS TO FUNCTIONS

        loadBtn.clicked.connect(self.selectWorm)
        saveBtn.clicked.connect(self.saveData)

        self.checkNames = True
        self.tp.valueChanged.connect(self.changeTp)
        self.sl.valueChanged.connect(self.updateCanvas1)
        self.sld1.valueChanged.connect(self.updateBC)
        self.sld2.valueChanged.connect(self.updateBC)

        self._488nmBtn.toggled.connect(self.radio488Clicked)
        self._561nmBtn.toggled.connect(self.radio561Clicked)
        self.CoolLEDBtn.toggled.connect(self.radioCoolLEDClicked)

        self.fig1.canvas.mpl_connect('scroll_event', self.wheelEvent)
Beispiel #3
0
    def create_main_frame(self):
        self.main_frame = QWidget()

        # Create the figure
        self.fig = Figure()
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.main_frame)

        # Create axes

        # the polar axis:
        rect = [0, 0, 1, 1]
        self.ax_p = self.fig.add_axes(rect,
                                      polar=True,
                                      frameon=False,
                                      aspect=1)
        self.ax_c = self.fig.add_axes(rect, aspect=1, frameon=False)

        # Set up the cartesian plot
        self.ax_c.get_xaxis().set_visible(False)
        self.ax_c.get_yaxis().set_visible(False)

        # Set up the polar polot
        self.ax_p.set_rlabel_position(
            0)  # get radial labels away from plotted line
        self.ax_p.grid(True)
        self.ax_p.autoscale(False)

        # Patch
        self.circles.render(self.ax_c)

        # Render initial values
        self.lines, = self.ax_p.plot([0], [0], 'r-')

        # Bind the 'pick' event for clicking on one of the bars
        #
        # self.canvas.mpl_connect('pick_event', self.on_pick)
        self.canvas.mpl_connect('button_press_event', self.press)
        self.canvas.mpl_connect('motion_notify_event', self.motion)
        self.canvas.mpl_connect('button_release_event', self.release)
        self.canvas.mpl_connect('scroll_event', self.scroll)

        # GUI controls
        #

        self.prev_button = QPushButton(u"🡰")
        self.prev_button.clicked.connect(self.prev)

        self.play_button = QPushButton(u"▶")
        self.play_button.clicked.connect(self.play)

        self.next_button = QPushButton(u"🡲")
        self.next_button.clicked.connect(self.next)

        spinbox_label = QLabel('Scan #')
        self.spinbox = QSpinBox()
        self.spinbox.setRange(0, 0)
        self.spinbox.setValue(0)
        self.spinbox.valueChanged.connect(self.valueChanged)
        self.spinbox.setFocusPolicy(Qt.NoFocus)

        #
        # Button layout
        #
        hbox = QHBoxLayout()

        for w in [
                self.prev_button, self.play_button, self.next_button,
                spinbox_label, self.spinbox
        ]:
            hbox.addWidget(w)
            hbox.setAlignment(w, Qt.AlignVCenter)

        vbox = QVBoxLayout()
        vbox.addWidget(self.canvas)
        # vbox.addWidget(self.mpl_toolbar)
        vbox.addLayout(hbox)

        self.main_frame.setLayout(vbox)
        self.setCentralWidget(self.main_frame)
 def addmplBodePhase(ZarcFitWindow, fig):
     ZarcFitWindow.canvas = FigureCanvas(fig)
     ZarcFitWindow.mplBodePhase.addWidget(ZarcFitWindow.canvas)
     ZarcFitWindow.canvas.draw()
Beispiel #5
0
    def __init__(self, parent=None):
        super(GraphUI, self).__init__(parent)

        #self.ui = Graph_UI.Ui_Form()
        #self.ui.setupUi(self)

        # a figure instance to plot on
        #self.figure = Figure()S
        self.figure = plt.figure()
        self.setWindowTitle("Analysis Result")
        # this is the Canvas Widget that displays the `figure`
        # it takes the `figure` instance as a parameter to __init__
        self.canvas = FigureCanvas(self.figure)

        # this is the Navigation widget
        # it takes the Canvas widget and a parent
        self.toolbar = NavigationToolbar(self.canvas, self)

        # O u r  - C o d e :
        userSymbol = "@"

        # If there are no analysis results
        if GraphUI.scriptsSum is None:
            GraphUI.scriptsSum = list()
            for i in range(0, 4):
                GraphUI.scriptsSum.insert(i, "")
            GraphUI.scriptsSum.insert(3, 0)
            GraphUI.scriptsSum[0] = list()
            for i in range(0, 8):
                GraphUI.scriptsSum[0].insert(i, 0)

        if GraphUI.prediction is None:
            GraphUI.prediction = list()
            for i in range(0, 8):
                GraphUI.prediction.insert(i, 0)

        if GraphUI.tweetsSum is None:
            GraphUI.tweetsSum = list()
            for i in range(0, 6):
                GraphUI.tweetsSum.insert(i, "")
            GraphUI.tweetsSum.insert(5, 0)
            GraphUI.tweetsSum[0] = list()
            for i in range(0, 8):
                GraphUI.tweetsSum[0].insert(i, 0)
            userSymbol = ""

        # Set the window
        self.setStyleSheet("background-color: rgb(255, 255, 255);")
        #self.window.setGeometry(self.window.x(), self.window.y() , 1000, 200)

        # Set the headline
        labelText = ""
        if self.window.character_text is not None:
            labelText = str(self.window.character_text)
        elif self.window.location_text is not None:
            labelText = str(self.window.location_text)
        elif self.window.house is not None:
            labelText = "House " + str(self.window.house)
        # Capitalize the name
        labelText = labelText[0].upper() + labelText[1:]
        lastNameIndex = labelText.find(" ") + 1
        labelText = labelText[:lastNameIndex] + labelText[lastNameIndex].upper(
        ) + labelText[lastNameIndex + 1:]
        q = '"'
        labelText += " in episode " + str(self.window.episode) + " - " + str(
            self.window.episode_text)

        self.label = QtGui.QLabel(labelText)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setStyleSheet(
            "background-color: rgb(255, 255, 255);"
            "color: rgb(0, 0, 0);"
            "margin-top: 0px; margin-bottom: 10px; margin-right: 15px; margin-left: 15px;"
            "padding: 0px;"
            "font-size: 35px;")

        # Set secondary headline
        self.second_label = QtGui.QLabel(
            "Produced from " + str(GraphUI.tweetsSum[5]) + " tweets and " +
            str(GraphUI.scriptsSum[3]) + " script lines. " +
            str(round(0.8 * GraphUI.prediction_size)) +
            " tweets used as a training-set and " +
            str(round(0.2 * GraphUI.prediction_size)) +
            " tweets used as a testing-set.")
        if GraphUI.prediction_size == 0:
            self.second_label = QtGui.QLabel(
                "Produced from " + str(GraphUI.tweetsSum[5]) + " tweets and " +
                str(GraphUI.scriptsSum[3]) +
                " script lines. No prediction was done, "
                "due to lack of relevant data.")
        self.second_label.setAlignment(QtCore.Qt.AlignCenter)
        self.second_label.setStyleSheet(
            "background-color: rgb(255, 255, 255);"
            "color: rgb(0, 0, 0);"
            "margin-top: 0px; margin-bottom: 10px; margin-right: 15px; margin-left: 15px;"
            "padding: 0px;"
            "font-size: 18px;")

        # Set the graph's size
        self.canvas.setFixedSize(QtCore.QSize(500, 500))
        #self.canvas.setMaximumWidth(1200)

        # Set the representative tweets

        self.tweet1 = QtGui.QLabel(
            str(GraphUI.tweetsSum[1]) + "\n\n" + userSymbol +
            str(GraphUI.tweetsSum[2]))
        self.tweet1.setWordWrap(True)
        self.tweet1.setMaximumWidth(350)
        self.tweet1.setStyleSheet(
            "background-color: rgb(29, 202, 255);"
            "color: rgb(0, 0, 0);"
            "margin-top: 5px; margin-bottom: 15px; margin-right: 15px; margin-left: 15px;"
            "padding: 15px;"
            "font-size: 18px;")

        self.tweet2 = QtGui.QLabel(
            str(GraphUI.tweetsSum[3]) + "\n\n" + userSymbol +
            str(GraphUI.tweetsSum[4]))
        self.tweet2.setWordWrap(True)
        self.tweet2.setMaximumWidth(350)
        self.tweet2.setStyleSheet(
            "background-color: rgb(29, 202, 255);"
            "color: rgb(0, 0, 0);"
            "margin-top: 15px; margin-bottom: 5px; margin-right: 15px; margin-left: 15px;"
            "padding: 15px;"
            "font-size: 18px;")

        # abort if there are no analysis results
        if userSymbol == "":
            self.tweet1.setStyleSheet("background-color: rgb(255, 255, 255);")
            self.tweet2.setStyleSheet("background-color: rgb(255, 255, 255);")

        # Set the restart and quit buttons

        #self.restart_button = QtGui.QPushButton('Restart')
        self.restart_button = QtGui.QPushButton()
        self.restart_button.clicked.connect(GraphUI.window.startMainPageUI)
        #self.restart_button.setMaximumWidth(91)
        #self.restart_button.setMaximumHeight(91)
        self.restart_button.setIcon(
            QtGui.QIcon(
                QtGui.QPixmap('./buttons/icons8-reboot-filled-100.png')))
        self.restart_button.setFixedSize(QtCore.QSize(90, 90))
        self.restart_button.setIconSize(QtCore.QSize(80, 80))

        #self.restart_button.setGeometry(self.restart_button.x(), self.restart_button.y(), 91, 91)
        #self.restart_button.setStyleSheet("background-color: #000000; color: black; border: 4.5px solid #111111; margin: 4px; border-radius: 40px;")

        #self.quit_button = QtGui.QPushButton('Quit')
        self.quit_button = QtGui.QPushButton()
        self.quit_button.clicked.connect(exit)
        self.quit_button.setIcon(
            QtGui.QIcon(QtGui.QPixmap('./buttons/icons8-shutdown-100.png')))
        self.quit_button.setFixedSize(QtCore.QSize(90, 90))
        self.quit_button.setIconSize(QtCore.QSize(80, 80))

        # set the layout

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.label)
        layout.addWidget(self.second_label)

        # Set an inner layout for the graph and the tweets
        middle_layout = QtGui.QHBoxLayout()

        # Set an inner-inner layout for the quit button
        leftbtn_layout = QtGui.QVBoxLayout()
        leftbtn_layout.addStretch()
        leftbtn_layout.addWidget(self.quit_button)
        middle_layout.addLayout(leftbtn_layout)

        middle_layout.addStretch()

        # Set an inner-inner layout for the graph and its toolbar
        graph_layout = QtGui.QVBoxLayout()
        graph_layout.addWidget(self.toolbar)
        graph_layout.addWidget(self.canvas)
        middle_layout.addLayout(graph_layout)

        # Set an inner-inner layout for the tweets
        tweets_layout = QtGui.QVBoxLayout()
        tweets_layout.addWidget(self.tweet1)
        tweets_layout.addWidget(self.tweet2)
        middle_layout.addLayout(tweets_layout)

        middle_layout.addStretch()

        # Set an inner-inner layout for the restart button
        rightbtn_layout = QtGui.QVBoxLayout()
        rightbtn_layout.addStretch()
        rightbtn_layout.addWidget(self.restart_button)
        middle_layout.addLayout(rightbtn_layout)

        layout.addLayout(middle_layout)

        # Set an inner layout for the buttons
        #down_layout = QtGui.QHBoxLayout()
        #down_layout.addWidget(self.quit_button)
        #down_layout.addStretch()
        #down_layout.addWidget(self.restart_button)
        #layout.addLayout(down_layout)

        self.setLayout(layout)

        # Clean the chosen parameters for the next round
        self.window.parameters = None
        self.window.episode = None
        self.window.episode_text = None
        self.window.category = None
        self.window.character = None
        self.window.character_text = None
        self.window.location = None
        self.window.location_text = None
        self.window.house = None

        # Show graph
        self.plot()
Beispiel #6
0
 def _create_elements(self):
     """ Create elements of this widget"""
     from matplotlib.figure import Figure
     from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
     
     # Create model and view of the variable selection
     # NOTE: One or two variables can be selected
     self.variables_model = QtGui.QStandardItemModel()
     self.variables_items = []
     for variable_name in sorted(self.current_collection.get_gui_variables()):
         item = QtGui.QStandardItem('%s' % variable_name)
         item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
         item.setData(QtCore.QVariant(QtCore.Qt.Unchecked),
                      QtCore.Qt.CheckStateRole)
         self.variables_model.appendRow(item)
         self.variables_items.append(item)
     
     self.variables_view = QtGui.QListView(self)
     self.variables_view.setModel(self.variables_model)
     
     # Create metrics selection list widget
     self.metrics_view = QtGui.QListWidget(self)
     self.metrics_view.setSelectionMode(QtGui.QListView.SingleSelection)
     self.metrics_items = []
     if not self.roc_curves.is_empty():  # If we can plot ROC curves
         self.metrics_items.append(QtGui.QListWidgetItem("ROC Curve",
                                                         self.metrics_view))
     for metric_name in sorted(self.current_collection.get_gui_metrics()):
         item = QtGui.QListWidgetItem('%s' % metric_name, self.metrics_view)
         self.metrics_items.append(item)
     self.metrics_items.append(QtGui.QListWidgetItem("Cost function",
                                                     self.metrics_view))
     
     # Add cost function box
     self.fpcost_label = QtGui.QLabel("False Positive Cost")
     self.fpcost_line_edit = QtGui.QLineEdit("1.0")
     self.fncost_label = QtGui.QLabel("False Negative Cost")
     self.fncost_line_edit = QtGui.QLineEdit("1.0") 
     
     # Create various buttons and connect them with the handler functions
     self.load_button = QtGui.QPushButton("&Load")
     self.connect(self.load_button, QtCore.SIGNAL('clicked()'), 
                  self._reload) #self._load_results_collection_from_file)
     
     self.draw_button = QtGui.QPushButton("&Draw or Toggle")
     self.connect(self.draw_button, QtCore.SIGNAL('clicked()'), 
                  self._draw_plot)
     
     self.hist_button = QtGui.QPushButton("&Histogram")
     self.connect(self.hist_button, QtCore.SIGNAL('clicked()'), 
                  self._draw_histogram)
     
     self.project_button = QtGui.QPushButton("&Filter")
     self.connect(self.project_button, QtCore.SIGNAL('clicked()'), 
                  self._project_popup)
     
     self.save_button = QtGui.QPushButton("&Save")
     self.connect(self.save_button, QtCore.SIGNAL('clicked()'), self._save)
     
     self.reset_button = QtGui.QPushButton("&Reset")
     self.connect(self.reset_button, QtCore.SIGNAL('clicked()'), self._reset)
     
     # Create matplotlib canvas 
     self.fig = Figure((12.0, 8.0), dpi=100)
     self.canvas = FigureCanvas(self.fig)
     self.canvas.setParent(self)
     
     # Create axes for plot
     self.axes = self.fig.add_subplot(111)
     
     # Text showing projection parameters
     self.project_params_label = QtGui.QLabel("No filtering.")
     self.project_params_label.setWordWrap(1)
     self.project_params_label.setFixedWidth(self.canvas.width())
     
     # Create layout of widget
     vlayout1 = QtGui.QVBoxLayout()
     hlayout1 = QtGui.QHBoxLayout()
     vlayout2 = QtGui.QVBoxLayout()
     vlayout2.addWidget(self.variables_view)
     vlayout2.addWidget(self.metrics_view)
     vlayout2.addWidget(self.fpcost_label)
     vlayout2.addWidget(self.fpcost_line_edit)
     vlayout2.addWidget(self.fncost_label)
     vlayout2.addWidget(self.fncost_line_edit)
     hlayout1.addLayout(vlayout2)
     hlayout1.addWidget(self.canvas)
     vlayout1.addLayout(hlayout1)
     
     hlayout2 = QtGui.QHBoxLayout()
     hlayout2.addWidget(self.load_button)
     hlayout2.addWidget(self.draw_button)
     hlayout2.addWidget(self.hist_button)
     hlayout2.addWidget(self.project_button)
     hlayout2.addWidget(self.save_button)
     hlayout2.addWidget(self.reset_button)
     
     vlayout1.addWidget(self.project_params_label)
     vlayout1.addLayout(hlayout2)
     
     self.setLayout(vlayout1)
    def plot_dataXY(self, MainWindow):

        counter = 0
        Position = np.array([0, 0, 0])
        ScatterX = []
        ScatterY = []
        ScatterAmp = []
        RangeXY = []
        DopplerXY = []
        rangeArray = []
        dopplerArray = []
        rangeDoppler = [[]]
        scene = QGraphicsScene()
        self.PlotXY.setScene(scene)
        figure = Figure()
        axes = figure.gca()
        scene1 = QGraphicsScene()
        self.Plot_RangeDoppler.setScene(scene1)
        figure1 = Figure()
        axes1 = figure1.gca()

        print(self.fileName)
        print(self.fin)
        for i in range(164):

            try:

                ScatterX, ScatterY, ScatterZ, ScatterAmp, RangeXY, DopplerXY, rangeArray, dopplerArray, rangeDoppler = processing(
                    self.fin, counter, Position)

                #axes.clf()

                #plt.style.use('dark_background')
                plt.clf()
                ax = plt.gca()
                #axes.clear()
                lines = axes.scatter(ScatterX,
                                     ScatterY,
                                     c=ScatterAmp,
                                     cmap=cm.rainbow)
                axes.set_title("Range Doppler")
                axes.set_xlim(xmin=-8, xmax=8)
                axes.set_ylim(ymin=0, ymax=8)
                axes.set_xlabel('left', text='X Position (m)')
                axes.set_ylabel('bottom', text='Y position (m)')
                #axes.grid()

                #mplcursors.cursor(lines)
                cursor = Cursor(axes,
                                horizOn=True,
                                vertOn=True,
                                color='green',
                                linewidth=2.0)

                #fig.canvas.mpl_connect('button_press_event',onclick)

                # ********************************************************************
                #axes1.clear()
                #axes1.imshow(rangeDoppler)
                axes1.imshow(rangeDoppler,
                             interpolation='nearest',
                             aspect='auto',
                             extent=[
                                 np.min(rangeArray),
                                 np.max(rangeArray),
                                 np.min(dopplerArray), -np.min(dopplerArray)
                             ])

                #axes1.grid()
                #axes.scatter(RangeXY,Doppler_Value)
                plt.draw()
                plt.pause(0.1)
                canvas = FigureCanvas(figure)

                canvas1 = FigureCanvas(figure1)

                canvas.setGeometry(QRect(10, 240, 331, 251))
                canvas1.setGeometry(QRect(850, 130, 481, 191))
                scene.addWidget(canvas)
                scene1.addWidget(canvas1)
            except BaseException:
                print("File no Traitable!!!")
Beispiel #8
0
    def __init__(self):
        super(MyWidget, self).__init__()
        self.brd = CvBridge()
        self.view = RGB
        ui_file = os.path.join(
            rospkg.RosPack().get_path('balloon_color_picker'), 'resource',
            'ColorPlugin.ui')
        rospy.loginfo('uifile {}'.format(ui_file))
        # self.log_info('uifile {}'.format(ui_file))
        loadUi(ui_file, self)
        # Give QObjects reasonable names
        self.setObjectName('ColorPluginUi')
        self.uav_name = os.environ['UAV_NAME']

        self.orig_h = 920
        self.orig_w = 1080
        self.hist_hsv_orig_h = 180
        self.hist_hsv_orig_w = 256
        self.hist_lab_orig_h = 256
        self.hist_lab_orig_w = 256
        self.hist_status = HSV
        self.select_status = HIST_SELECTION
        self.crop_stat = IMG
        self.hist_mask = np.zeros([self.hist_hsv_orig_h, self.hist_hsv_orig_w])
        self.hist_mask_lab = np.zeros(
            [self.hist_lab_orig_h, self.hist_lab_orig_w])
        self.cur_hist_hs = None
        self.cur_hist_ab = None
        self.selected_count = 0
        # ROS services

        # #{ ros services

        self.sigma_caller = rospy.ServiceProxy('change_sigma', ChangeSigma)
        self.sigma_lab_caller = rospy.ServiceProxy('change_sigma_lab',
                                                   ChangeSigmaLab)
        self.caller = rospy.ServiceProxy('capture', Capture)
        self.capture_cropped_srv = rospy.ServiceProxy('capture_cropped',
                                                      CaptureCropped)
        self.get_count = rospy.ServiceProxy('get_count', GetCount)
        self.clear_count = rospy.ServiceProxy('clear_count', ClearCount)
        self.get_config = rospy.ServiceProxy('get_config', GetConfig)
        self.get_params = rospy.ServiceProxy('get_params', Params)
        self.freeze_service = rospy.ServiceProxy('freeze', Freeze)
        self.update_service = rospy.ServiceProxy('change_obd', UpdateObd)
        self.change_callback = rospy.ServiceProxy('change_callback',
                                                  ChangeCallback)
        self.capture_hist = rospy.ServiceProxy('capture_hist', CaptureHist)

        # #} end of ros services        rospy.wait_for_service('capture')

        rospy.loginfo(
            'waiting for service "get_params" from computation module \n if this is more than 5 secs check for topic remapping'
        )
        # self.log_info('waiting for service')
        rospy.loginfo('uav_name {}'.format(os.environ['UAV_NAME']))
        # self.log_info('uav_name {}'.format(os.environ['UAV_NAME']))
        rospy.wait_for_service('get_params')

        self.config_path, self.save_path, self.circled_param, self.circle_filter_param, self.circle_luv_param, self.object_detect_param, self.save_to_drone = self.set_params(
        )
        # SUBS
        # #{ ros subs

        self.balloon_sub = rospy.Subscriber(self.circled_param,
                                            RosImg,
                                            self.img_callback,
                                            queue_size=1)
        self.filter_sub = rospy.Subscriber(self.circle_filter_param,
                                           RosImg,
                                           self.filter_callback,
                                           queue_size=1)
        self.filter_luv = rospy.Subscriber(self.circle_luv_param,
                                           RosImg,
                                           self.luv_callback,
                                           queue_size=1)
        self.obj_det_sb = rospy.Subscriber(self.object_detect_param,
                                           RosImg,
                                           self.obj_det_callback,
                                           queue_size=1)
        # self.hsv = message_filters.Subscriber(self.circle_filter_param, RosImg)
        # self.luv = message_filters.Subscriber(self.circle_luv_param, RosImg)

        # self.ts = message_filters.ApproximateTimeSynchronizer([self.luv,  self.hsv], 1, 0.5)
        # self.ts.registerCallback(self.both_callback)

        # #} end of ros subs

        self.colors = self.load_config(self.config_path)
        self.add_buttons(self.colors)

        # # DEFAULT IMAGE
        # img = cv2.imread('/home/mrs/balloon_workspace/src/ros_packages/balloon_color_picker/data/blue.png')

        # cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

        # h,w,c = img.shape
        # q_img = QImage(img.data, w,h,3*w, QImage.Format_RGB888)

        # q = QPixmap.fromImage(q_img)

        #DIRECTORY
        #default
        self.directory.setText(self.save_path + "Red.yaml")
        self.color_name = "red"
        self.save_button.clicked.connect(self.save_config)

        #PLOT

        self.figure = Figure()
        self.figure_luv = Figure()
        self.canvas = FigureCanvas(self.figure)
        self.canvas_luv = FigureCanvas(self.figure_luv)
        self.canvas.setParent(self.inner)
        # self.toolbar = NavigationToolbar(self.canvas,self)
        # self.toolbar_luv = NavigationToolbar(self.canvas_luv,self)
        # self.toolbar.setParent(self.inner)
        # self.toolbar_luv.setParent(self.inner_luv)
        self.canvas_luv.setParent(self.inner_luv)
        self.inner_luv.hide()
        self.inner_luv_hist.hide()

        #SLIDER CONFIG

        # #{ slider config

        self.sigma_slider.setRange(0, 100)
        self.sigma_slider.setSingleStep(1)
        self.sigma_slider.setValue(6)

        self.sigma_slider.valueChanged.connect(self.slider_event)

        self.sigma_slider_s.setRange(0, 100)
        self.sigma_slider_s.setSingleStep(1)
        self.sigma_slider_s.setValue(6)

        self.sigma_slider_s.valueChanged.connect(self.slider_event)

        self.sigma_slider_v.setRange(0, 100)
        self.sigma_slider_v.setSingleStep(1)
        self.sigma_slider_v.setValue(80)

        self.sigma_slider_v.valueChanged.connect(self.slider_event)

        self.sigma_slider_lab.setRange(0, 100)
        self.sigma_slider_lab.setSingleStep(1)
        self.sigma_slider_lab.setValue(80)

        self.sigma_slider_lab.valueChanged.connect(self.slider_event_lab)

        self.sigma_slider_a.setRange(0, 100)
        self.sigma_slider_a.setSingleStep(1)
        self.sigma_slider_a.setValue(6)

        self.sigma_slider_a.valueChanged.connect(self.slider_event_lab)

        self.sigma_slider_b.setRange(0, 100)
        self.sigma_slider_b.setSingleStep(1)
        self.sigma_slider_b.setValue(6)

        self.sigma_slider_b.valueChanged.connect(self.slider_event_lab)

        # #} end of slider config

        # #{ font configs

        #SIGMA TEXT
        font = self.font()
        font.setPointSize(16)
        self.sigma_value.setFont(font)
        self.sigma_value_s.setFont(font)
        self.sigma_value_v.setFont(font)
        self.sigma_value_lab.setFont(font)
        self.sigma_value_a.setFont(font)
        self.sigma_value_b.setFont(font)
        #IMAGE COUNT TEXT
        self.image_count.setFont(font)
        #BOX FOR BUTTONS font
        # self.color_buttons.setFont(font)
        font.setPointSize(14)
        self.sigma_value.setFont(font)
        self.log_text.setFont(font)

        #LAB HSV TEXT
        font.setPointSize(23)
        self.label_lab.setFont(font)
        self.label_lab.hide()
        self.label_hsv.setFont(font)
        self.label_hsv.hide()

        # #} end of font configs

        # BUTTONS
        self.change.clicked.connect(self.switch_view_hsv)
        self.change_both.clicked.connect(self.switch_view_both)
        self.change_luv.clicked.connect(self.switch_view_luv)
        self.change_object.clicked.connect(self.switch_view_object_detect)
        self.capture_button.clicked.connect(self.capture)
        self.clear_button.clicked.connect(self.clear)
        self.freeze_button.clicked.connect(self.freeze)
        self.update_button.clicked.connect(self.update_obd)
        # self.wdg_img.setPixmap(q)
        # self.box_layout.addWidget(self.toolbar)
        # self.inner.box_layout.addWidget(self.canvas)
        #shortcuts

        self.short_capture = QShortcut(QKeySequence("C"), self)
        self.short_capture.activated.connect(self.capture)
        self.short_hsv = QShortcut(QKeySequence("1"), self)
        self.short_hsv.activated.connect(self.switch_view_hsv)
        self.short_lab = QShortcut(QKeySequence("2"), self)
        self.short_lab.activated.connect(self.switch_view_luv)
        self.short_object_detect = QShortcut(QKeySequence("3"), self)
        self.short_object_detect.activated.connect(
            self.switch_view_object_detect)
        self.short_object_detect_update = QShortcut(QKeySequence("U"), self)
        self.short_object_detect_update.activated.connect(self.update_obd)
        self.short_both = QShortcut(QKeySequence("4"), self)
        self.short_both.activated.connect(self.switch_view_both)
        self.short_save = QShortcut(QKeySequence("S"), self)
        self.short_save.activated.connect(self.save_config)
        self.short_clear = QShortcut(QKeySequence("N"), self)
        self.short_clear.activated.connect(self.clear)
        self.short_freeze = QShortcut(QKeySequence("F"), self)
        self.short_freeze.activated.connect(self.freeze)

        vbx = QVBoxLayout()
        but_hsv = QRadioButton()
        but_hsv.setText('HSV')
        but_hsv.setChecked(True)
        self.color_space = 'HSV'
        but_hsv.clicked.connect(self.set_colorspace_hsv)
        vbx.addWidget(but_hsv)
        but_lab = QRadioButton()
        but_lab.setText('LAB')
        but_lab.clicked.connect(self.set_colorspace_lab)
        vbx.addWidget(but_lab)
        vbx.addStretch(1)

        self.radio_buttons.setLayout(vbx)
        vbx_method = QVBoxLayout()
        but_lut = QRadioButton()
        but_lut.setText('LUT')
        but_lut.setChecked(False)
        but_lut.clicked.connect(self.set_method_lut)
        vbx_method.addWidget(but_lut)

        but_thr = QRadioButton()
        but_thr.setText('Threshold')
        but_thr.setChecked(True)
        but_thr.clicked.connect(self.set_method_thr)
        vbx_method.addWidget(but_thr)
        vbx.addStretch(1)

        self.radio_buttons_method.setLayout(vbx_method)

        self.load_method = 'THR'

        # self.mousePressEvent.connect(self.mousePressEvent)
        self.plotted = False

        self._rubber = None

        self.frozen = False
    def create_main_frame(self):
        self.main_frame = QWidget()

        self.dpi = 300
        self.fig = Figure(dpi=self.dpi, )
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.main_frame)

        self.axes = self.fig.add_axes([0, 0, 1, 1])
        self.axes.set_aspect(1)
        self.axes.set_frame_on(False)
        self.axes.get_xaxis().set_visible(False)
        self.axes.get_yaxis().set_visible(False)

        self.mpl_toolbar = NavigationToolbar2QT(self.canvas, self.main_frame)

        # Other GUI controls

        self.reference_contrast_label = QLabel('reference contrast:')
        self.reference_contrast_slider = QSlider(Qt.Horizontal)
        self.reference_contrast_slider.setMinimumWidth(200)
        self.reference_contrast_slider.setRange(0, 6)
        self.reference_contrast_slider.setValue(3)
        self.matching_contrast_label = QLabel('matching contrast:')
        self.matching_contrast_slider = QSlider(Qt.Horizontal)
        self.matching_contrast_slider.setMinimumWidth(200)
        self.matching_contrast_slider.setMinimumWidth(200)
        self.matching_contrast_slider.setRange(0, 6)
        self.matching_contrast_slider.setValue(3)

        self.radiobutton_reference = QRadioButton('Reference')
        self.radiobutton_matching = QRadioButton('Matching')
        self.radiobutton_both = QRadioButton('Both')
        self.radiobutton_both.setChecked(True)

        self.label_Xoffset = QLabel('X offset:')
        self.spinbox_Xoffset = QSpinBox()
        self.spinbox_Xoffset.setRange(-2000, 2000)
        self.spinbox_Xoffset.setSingleStep(10)
        self.spinbox_Xoffset.setMinimumWidth(60)

        self.label_Yoffset = QLabel('Y offset:')
        self.spinbox_Yoffset = QSpinBox()
        self.spinbox_Yoffset.setRange(-2000, 2000)
        self.spinbox_Yoffset.setSingleStep(10)
        self.spinbox_Yoffset.setMinimumWidth(60)

        self.label_rotation = QLabel('Rotation:')
        self.spinbox_rotation = QSpinBox()
        self.spinbox_rotation.setRange(-180, 180)
        self.spinbox_rotation.setMinimumWidth(60)

        self.label_zoom = QLabel('Zoom:    ')
        self.doubleSpinbox_zoom = QDoubleSpinBox()
        self.doubleSpinbox_zoom.setRange(0.001, 64.)
        self.doubleSpinbox_zoom.setValue(1.)
        self.doubleSpinbox_zoom.setMinimumWidth(60)
        self.doubleSpinbox_zoom.setDecimals(3)

        self.label_RPath = QLabel('Reference Dictionary/Map Path(s):')
        self.textbrowser_RPath = QTextBrowser()
        self.textbrowser_RPath.setMinimumWidth(200)
        self.button_RPath = QPushButton('Get Path')

        self.label_MPath = QLabel('Matching Dictionary/Map Path(s):')
        self.textbrowser_MPath = QTextBrowser()
        self.textbrowser_MPath.setMinimumWidth(200)
        self.button_MPath = QPushButton('Get Path')

        self.button_draw = QPushButton('Draw')
        self.button_draw.setMinimumWidth(100)
        self.button_draw.setFixedHeight(100)

        #
        # Layout with box sizers
        #

        vbox_Reference = QVBoxLayout()
        for R in [self.label_RPath, self.textbrowser_RPath, self.button_RPath]:
            vbox_Reference.addWidget(R)
            vbox_Reference.setAlignment(R, Qt.AlignLeft)

        vbox_Match = QVBoxLayout()
        for M in [self.label_MPath, self.textbrowser_MPath, self.button_MPath]:
            vbox_Match.addWidget(M)
            vbox_Match.setAlignment(M, Qt.AlignLeft)

        vbox_checkbox = QVBoxLayout()
        for P in [
                self.radiobutton_reference, self.radiobutton_matching,
                self.radiobutton_both
        ]:
            vbox_checkbox.addWidget(P)
            vbox_checkbox.setAlignment(P, Qt.AlignLeft)

        vbox_contrast = QVBoxLayout()
        for P in [
                self.reference_contrast_label, self.reference_contrast_slider,
                self.matching_contrast_label, self.matching_contrast_slider
        ]:
            vbox_contrast.addWidget(P)
            vbox_contrast.setAlignment(P, Qt.AlignLeft)

        hbox_Zoom = QHBoxLayout()
        for Z in [self.label_zoom, self.doubleSpinbox_zoom]:
            hbox_Zoom.addWidget(Z)
            hbox_Zoom.setAlignment(Z, Qt.AlignVCenter)

        hbox_Xoffset = QHBoxLayout()
        for X in [self.label_Xoffset, self.spinbox_Xoffset]:
            hbox_Xoffset.addWidget(X)
            hbox_Xoffset.setAlignment(X, Qt.AlignVCenter)

        hbox_Yoffset = QHBoxLayout()
        for Y in [self.label_Yoffset, self.spinbox_Yoffset]:
            hbox_Yoffset.addWidget(Y)
            hbox_Yoffset.setAlignment(Y, Qt.AlignVCenter)

        hbox_Rotation = QHBoxLayout()
        for R in [self.label_rotation, self.spinbox_rotation]:
            hbox_Rotation.addWidget(R)
            hbox_Rotation.setAlignment(R, Qt.AlignVCenter)

        vbox_Adjustment = QVBoxLayout()
        for A in [hbox_Zoom, hbox_Xoffset, hbox_Yoffset, hbox_Rotation]:
            vbox_Adjustment.addLayout(A)
            vbox_Adjustment.setAlignment(A, Qt.AlignLeft)

        vbox_Adjustment2 = QHBoxLayout()
        for A in [vbox_Adjustment, self.button_draw]:
            try:
                vbox_Adjustment2.addLayout(A)
            except Exception:
                vbox_Adjustment2.addWidget(A)
            vbox_Adjustment2.setAlignment(A, Qt.AlignVCenter)

        vbox_right = QVBoxLayout()
        for RT in [
                vbox_Reference, vbox_Match, vbox_contrast, vbox_checkbox,
                vbox_Adjustment2
        ]:
            vbox_right.addLayout(RT)
            vbox_right.setAlignment(RT, Qt.AlignLeft)
        vbox_right.insertSpacing(1, 30)
        vbox_right.insertSpacing(3, 30)
        vbox_right.insertSpacing(5, 30)

        vbox_plot = QVBoxLayout()
        for P in [self.canvas, self.mpl_toolbar]:
            vbox_plot.addWidget(P)

        hbox = QHBoxLayout()
        for L in [vbox_plot, vbox_right]:
            hbox.addLayout(L)
            hbox.setAlignment(L, Qt.AlignVCenter)

        self.main_frame.setLayout(hbox)
        self.setCentralWidget(self.main_frame)
Beispiel #10
0
 def __init__(self, ):
     super(Main, self).__init__()
     self.setupUi(self)
     self.setWindowTitle(
         'SMÁSJÁ (Sjá Myndræna Ástandssögu Skála og Jaðarkera í Álframleiðslu)'
     )
     self.setWindowIcon(QtGui.QIcon('microscope.ico'))
     #Upphafsstilla nokkur gildi
     self.msglabel.hide()
     self.textfixer.setStyleSheet('QWidget#textfixer {border:none}')
     self.potlistbox.setStyleSheet('QWidget#potlistbox {border:none}')
     self.header = self.xlist.horizontalHeader()
     self.header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
     self.header.setSectionResizeMode(
         1, QtWidgets.QHeaderView.ResizeToContents)
     self.xlist.setHorizontalHeaderLabels(['X', 'Y'])
     self.keyboard = Controller()  #til að gera macros
     self.threadpool = QThreadPool()
     #Skilgreini breytur
     self.pot_or_line = 'line'  #segir til um hvort pot eða line sé valið til að teikna
     self.save_location = path.expanduser("~").replace(
         "\\", "/") + '/'  #default save staðsetning er heimasvæði notanda
     self.graphed_data = ''  #heldur utan um hvað er til sýnis til að setja í save file nafnið
     #Skilgreini subplots
     self.fig = Figure()
     self.one_ax = Axis(self.fig, 111)
     self.one_ax_a2 = SecondaryAxis(self.one_ax)
     self.one_ax.ax.set_visible(False)  #fela stóru myndina í byrjun
     self.one_ax_a2.ax.set_visible(False)
     self.left_ax = Axis(self.fig, 121)
     self.left_ax_a2 = SecondaryAxis(self.left_ax)
     self.right_ax = Axis(self.fig, 122)
     self.right_ax_a2 = SecondaryAxis(self.right_ax)
     self.curr_ax = self.left_ax  #default byrjunarstaður er vinstri mynd
     self.canvas = FigureCanvas(self.fig)  #Sér um birtingu á gröfum
     self.plotLayout.addWidget(self.canvas)  #bæti striga á interface-ið
     #Skilgreini shortcuts
     self.save_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+S'),
                                              self)
     self.save_shortcut.activated.connect(self.saveGraph)
     self.updateData_shortcut = QtWidgets.QShortcut(
         QtGui.QKeySequence('Ctrl+U'), self)
     self.updateData_shortcut.activated.connect(self.prepareUpdate)
     self.undo_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+Z'),
                                              self)
     self.undo_shortcut.activated.connect(self.undo)
     self.clearAx_shortcut = QtWidgets.QShortcut(
         QtGui.QKeySequence('Ctrl+A'), self)
     self.clearAx_shortcut.activated.connect(self.clearAxis)
     #tengist oracle gagnagrunni
     conn = 'REDACTED' = connect.cursor()
     self.xvals = ["REDACTED"]  #Fyrirfram skilgreind x og y gildi
     self.yvals = ["REDACTED"]
     self.populateComboBox(self.xbox, self.xvals)  #bæti í drop down listann
     self.populateComboBox(self.ybox, self.yvals)
     c.execute("SELECT DISTINCT(REDACTED) FROM REDACTED"
               )  #vel öll kerskálanúmer úr töflu
     c.execute(
         "SELECT DISTINCT(REDACTED) FROM REDACTED")  #vel öll ár úr töflu
     self.yearbox.addItem('')  #autt gildi sem táknar öll ár í boði
     self.populateComboBox(self.yearbox, [row[0] for row in c.fetchall()])
     c.close()
     self.potbutton.toggled.connect(
         self.updatePotOrLine
     )  #Þegar ýtt er á "Ker" radio takkann tengjast updatePotOrLine fallinu
     self.potroombutton.toggled.connect(
         self.updatePotOrLine)  #"Kerskáli" radio takkinn
     self.analysismode.toggled.connect(
         self.analyzePot)  #Þegar greiningarhamur er gerður virkur
     self.secondarybox.toggled.connect(
         self.switchAx)  #"Teikna á annan y-ás" boxið
     self.leftgraph.toggled.connect(self.changeGraphs)  #Vinstri gluggi
     self.rightgraph.toggled.connect(self.changeGraphs)  #Hægri gluggi
     self.multpotplots.toggled.connect(self.analysisCheck)  #Mörg gröf á ker
     self.populateComboBox(self.colorbox, [
         'Blár', 'Grænn', 'Rauður', 'Ljósblár', 'Fjólublár', 'Gulur',
         'Svartur'
     ])  #Fylli lita-dropdownlistann
     self.updateButton.pressed.connect(
         self.checkUpdateMethod)  #"Uppfæra" takkinn
     self.clearchart.pressed.connect(
         self.clearGraph)  #"Hreinsa graf" takkinn
     self.prodButton.pressed.connect(self.plotProd)  #Framleiðslugögn
     self.pottapbutton.pressed.connect(self.potTappingData)  #Áltökugögn
     self.folderbutton.pressed.connect(self.selectFolder)  #Velja möppu
     self.savebutton.pressed.connect(self.saveGraph)
     self.clearaxis.pressed.connect(self.clearAxis)
     self.curr_x = self.xboxConvert()  #Valið x-gildi
Beispiel #11
0
    def __init__(self, parent=None, name=None, fl=0):
        """
        Descript. :
        """
        QtGui.QWidget.__init__(self, parent, QtCore.Qt.WindowFlags(fl))

        if name is not None:
            self.setObjectName(name)

        # Hardware objects ----------------------------------------------------
        self._beamline_setup_hwobj = None
        self._beam_center_hwobj = None

        # Internal variables --------------------------------------------------
        array = []
        array.append([])
        array.append([])

        self._array2ndXtal = []
        self._array2ndXtal.append([])
        self._array2ndXtal.append([])

        self._arraySlit1 = []
        self._arraySlit1.append(array)
        self._arraySlit1.append(array)

        self._arraySlit2 = []
        self._arraySlit2.append(array)
        self._arraySlit2.append(array)

        self.figure2ndXtal = Figure()
        self.ax2ndXtal = self.figure2ndXtal.add_subplot(111)
        self.canvas2ndXtal = FigureCanvas(self.figure2ndXtal)

        self.figureHorSlit1 = Figure()
        self.axHorSlit1 = self.figureHorSlit1.add_subplot(111)
        self.canvasHorSlit1 = FigureCanvas(self.figureHorSlit1)

        self.figureVerSlit1 = Figure()
        self.axVerSlit1 = self.figureVerSlit1.add_subplot(111)
        self.canvasVerSlit1 = FigureCanvas(self.figureVerSlit1)

        self.figureHorSlit2 = Figure()
        self.axHorSlit2 = self.figureHorSlit2.add_subplot(111)
        self.canvasHorSlit2 = FigureCanvas(self.figureHorSlit2)

        self.figureVerSlit2 = Figure()
        self.axVerSlit2 = self.figureVerSlit2.add_subplot(111)
        self.canvasVerSlit2 = FigureCanvas(self.figureVerSlit2)

        # Properties ----------------------------------------------------------

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self.beam_center_widget_layout = uic.loadUi(os.path.join(\
             os.path.dirname(__file__),
             "ui_files/Qt4_beam_centering_widget_layout.ui"))

        self.toolbar2ndXtal = NavigationToolbar(
            self.canvas2ndXtal,
            self.beam_center_widget_layout.mplPitch2ndXtalWindow,
            coordinates=True)
        self.toolbarHorSlit1 = NavigationToolbar(
            self.canvasHorSlit1,
            self.beam_center_widget_layout.mplHorSlit1Window,
            coordinates=True)
        self.toolbarVerSlit1 = NavigationToolbar(
            self.canvasVerSlit1,
            self.beam_center_widget_layout.mplVerSlit1Window,
            coordinates=True)
        self.toolbarHorSlit2 = NavigationToolbar(
            self.canvasHorSlit2,
            self.beam_center_widget_layout.mplHorSlit2Window,
            coordinates=True)
        self.toolbarVerSlit2 = NavigationToolbar(
            self.canvasVerSlit2,
            self.beam_center_widget_layout.mplVerSlit2Window,
            coordinates=True)

        self.beam_center_widget_layout.mpl2ndXtalVl.addWidget(
            self.canvas2ndXtal)
        self.beam_center_widget_layout.mpl2ndXtalVl.addWidget(
            self.toolbar2ndXtal)

        self.beam_center_widget_layout.mplHorVlSlit1.addWidget(
            self.canvasHorSlit1)
        self.beam_center_widget_layout.mplHorVlSlit1.addWidget(
            self.toolbarHorSlit1)
        self.beam_center_widget_layout.mplVerVlSlit1.addWidget(
            self.canvasVerSlit1)
        self.beam_center_widget_layout.mplVerVlSlit1.addWidget(
            self.toolbarVerSlit1)

        self.beam_center_widget_layout.mplHorVlSlit2.addWidget(
            self.canvasHorSlit2)
        self.beam_center_widget_layout.mplHorVlSlit2.addWidget(
            self.toolbarHorSlit2)
        self.beam_center_widget_layout.mplVerVlSlit2.addWidget(
            self.canvasVerSlit2)
        self.beam_center_widget_layout.mplVerVlSlit2.addWidget(
            self.toolbarVerSlit2)

        # Configure validator of input edit boxes
        self.beam_center_widget_layout.distance2ndXtalEdit.setValidator(
            QtGui.QDoubleValidator(0.9999, 9.9999, 4))
        self.beam_center_widget_layout.step2ndXtalEdit.setValidator(
            QtGui.QDoubleValidator(0.999999, 9.999999, 6))

        self.beam_center_widget_layout.distanceHorSlit1Edit.setValidator(
            QtGui.QDoubleValidator(0.99, 999.99, 2))
        self.beam_center_widget_layout.distanceVerSlit1Edit.setValidator(
            QtGui.QDoubleValidator(0.99, 999.99, 2))
        self.beam_center_widget_layout.stepSlit1Edit.setValidator(
            QtGui.QDoubleValidator(0.999, 9.999, 3))

        self.beam_center_widget_layout.distanceHorSlit2Edit.setValidator(
            QtGui.QDoubleValidator(0.99, 999.99, 2))
        self.beam_center_widget_layout.distanceVerSlit2Edit.setValidator(
            QtGui.QDoubleValidator(0.99, 999.99, 2))
        self.beam_center_widget_layout.stepSlit2Edit.setValidator(
            QtGui.QDoubleValidator(0.999, 9.999, 3))

        # Set enable/disable buttons
        self.beam_center_widget_layout.startCenterButton.setEnabled(True)
        self.beam_center_widget_layout.cancelCenterButton.setEnabled(False)

        # Layout --------------------------------------------------------------
        __main_vlayout = QtGui.QVBoxLayout(self)
        __main_vlayout.addWidget(self.beam_center_widget_layout)
        __main_vlayout.setSpacing(0)
        __main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.beam_center_widget_layout.defaultParamCheck.stateChanged.connect(\
             self.defaultParamCheck_change)

        self.beam_center_widget_layout.distance2ndXtalEdit.textChanged.connect(\
             self.distance2ndXtalEdit_change)
        self.beam_center_widget_layout.step2ndXtalEdit.textChanged.connect(\
             self.step2ndXtalEdit_change)
        self.beam_center_widget_layout.fullPath2ndXtalCheck.stateChanged.connect(\
             self.fullPath2ndXtalCheck_change)
        self.beam_center_widget_layout.centroid2ndXtalCheck.stateChanged.connect(\
             self.centroid2ndXtalCheck_change)
        self.beam_center_widget_layout.center2ndXtalCheck.stateChanged.connect(\
             self.center2ndXtalCheck_change)

        self.beam_center_widget_layout.distanceHorSlit1Edit.textChanged.connect(\
             self.distanceHorSlit1Edit_change)
        self.beam_center_widget_layout.distanceVerSlit1Edit.textChanged.connect(\
             self.distanceVerSlit1Edit_change)
        self.beam_center_widget_layout.stepSlit1Edit.textChanged.connect(\
             self.stepSlit1Edit_change)
        self.beam_center_widget_layout.fullPathSlit1Check.stateChanged.connect(\
             self.fullPathSlit1Check_change)
        self.beam_center_widget_layout.centroidSlit1Check.stateChanged.connect(\
             self.centroidSlit1Check_change)
        self.beam_center_widget_layout.centerSlit1Check.stateChanged.connect(\
             self.centerSlit1Check_change)

        self.beam_center_widget_layout.distanceHorSlit2Edit.textChanged.connect(\
             self.distanceHorSlit2Edit_change)
        self.beam_center_widget_layout.distanceVerSlit2Edit.textChanged.connect(\
             self.distanceVerSlit2Edit_change)
        self.beam_center_widget_layout.stepSlit2Edit.textChanged.connect(\
             self.stepSlit2Edit_change)
        self.beam_center_widget_layout.fullPathSlit2Check.stateChanged.connect(\
             self.fullPathSlit2Check_change)
        self.beam_center_widget_layout.centroidSlit2Check.stateChanged.connect(\
             self.centroidSlit2Check_change)
        self.beam_center_widget_layout.centerSlit2Check.stateChanged.connect(\
             self.centerSlit2Check_change)

        self.beam_center_widget_layout.startCenterButton.clicked.connect(\
             self.startCenter)
        self.beam_center_widget_layout.cancelCenterButton.clicked.connect(\
             self.cancelCenter)
Beispiel #12
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
        self.setGeometry(630, 80, 800, 800)
        self.setWindowTitle('Hypersquare control!!!')
        self.setWindowIcon(QtGui.QIcon('images.png'))

        self.fig = Figure()
        self.canvas = FigureCanvas(self.fig)

        btnQ = QtGui.QPushButton('Quit', self)
        btnQ.clicked.connect(QtCore.QCoreApplication.instance().quit)

        grid = QtGui.QGridLayout()
        self.setLayout(grid)
        grid.addWidget(self.canvas)

        def lhs():
            # Initialisation:
            nV = 2
            nS = self.sl.value()
            # Grid Setup
            ax = self.fig.add_subplot(111)
            # Creation of a list dictionnary
            k = 1
            x = {}
            x[k] = []
            # Loop elements (part1)
            for i in range(1, (nV + 1)):
                x1 = []

                for j in range(1, (nS + 1)):
                    a = ((float(j) - 1) / nS)
                    b = ((float(j)) / nS)
                    listesample = random.uniform(a, b)
                    x1.append(listesample)
                    # Select a random number nP times between each Sample and for each Var (part2)
                for k in range(1, nS + 1):
                    listechoice = random.choice(x1)
                    x.setdefault(k, []).append(listechoice)
                    x1.remove(listechoice)
            # pprint(x)

            data1 = [float(x[k][0]) for k in range(1, nS + 1)]
            data2 = [float(x[k][1]) for k in range(1, nS + 1)]

            ax.clear()
            ax.plot(data1, data2, 'b.')
            if nS < 26:
                ax.set_xticks(numpy.arange(0, 1, (1 / float(nS))))
                ax.set_yticks(numpy.arange(0, 1, (1 / float(nS))))
            ax.grid(True)
            self.canvas.draw()

        def function():
            lhs()

        btnR = QtGui.QPushButton("Run", self)
        btnR.clicked.connect(function)

        self.sp = QtGui.QSpinBox(self)
        self.sp.setRange(0, 100)
        self.sp.setSingleStep(1)

        self.toolbar = NavigationToolbar(self.canvas, self)

        self.sl = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.sl.setMinimum(0)
        self.sl.setMaximum(100)
        self.sl.setValue(0)
        self.sl.setTickInterval(10)
        self.sl.setTickPosition(QtGui.QSlider.TicksBelow)
        self.sl.valueChanged.connect(self.sp.setValue)
        self.sp.valueChanged.connect(self.sl.setValue)

        grid.addWidget(btnR)
        grid.addWidget(btnQ)
        grid.addWidget(self.sl)
        grid.addWidget(self.sp)
        grid.addWidget(self.toolbar)
Beispiel #13
0
 def __init__(self):
     # 新建一个Figure
     self.figure = Figure()
     # 将Figure转换为Qt4 Widget控件以便插入Qt4界面
     self.canvas = FigureCanvas(self.figure)
Beispiel #14
0
    def initUI(self):
        self.setGeometry(600, 300, 1300, 600)
        self.setFixedSize(1300, 600)
        self.center()
        self.setWindowTitle('Health Statistics & Analysis')
        self.setWindowIcon(QtGui.QIcon('hospital-2.png'))
        grid = QtGui.QGridLayout()
        self.setLayout(grid)

        bar = QtGui.QMenuBar()
        file = bar.addMenu('File')
        file.addAction('New')
        save = QtGui.QAction('Save', self)
        file.addAction(save)
        edit = bar.addMenu('Edit')
        edit.addAction('Copy')
        edit.addAction('paste')
        quit = bar.addMenu('Quit')
        exit = QtGui.QAction('Exit', self)
        quit.addAction(exit)
        grid.addWidget(bar, 0, 0, 1, 2)

        pic = QtGui.QLabel()
        pic.setPixmap(QtGui.QPixmap('electrocardiogram.png'))
        pic.resize(pic.sizeHint())
        label1 = QtGui.QLabel('Data Manipulation')
        label1.setFont(QtGui.QFont('Calibri', 11, QtGui.QFont.Bold))
        file_import = QtGui.QPushButton('Import File')
        file_import.resize(file_import.sizeHint())
        self.connect(file_import, SIGNAL('clicked()'), self.file_dialog)
        self.connect(self, SIGNAL('main2closed()'), self.file_clear)
        button2 = QtGui.QPushButton('Display DataFrame')
        button2.resize(button2.sizeHint())
        self.connect(button2, SIGNAL('clicked()'), self.disp_df)
        self.connect(self, SIGNAL('main2closed()'), self.df_clear)

        describ = QtGui.QPushButton('Description')
        describ.clicked.connect(self.description)

        sublayout1 = QtGui.QGridLayout()
        sublayout1.addWidget(pic, 0, 0)
        sublayout1.addWidget(label1, 1, 0)
        sublayout1.addWidget(file_import, 2, 0)
        sublayout1.addWidget(button2, 2, 1)

        sublayout1.addWidget(describ, 3, 0)
        grid.addLayout(sublayout1, 1, 0)

        label2 = QtGui.QLabel('Statistical Visualization')
        label2.setFont(QtGui.QFont('Calibri', 11, QtGui.QFont.Bold))
        button4 = QtGui.QPushButton('Distribution(Histogram)')
        button4.resize(button4.sizeHint())
        self.connect(button4, SIGNAL('clicked()'), self.Hist)
        self.connect(self, SIGNAL('main2closed()'), self.hist_clear)
        button5 = QtGui.QPushButton('Time Chart Series')
        button5.resize(button5.sizeHint())
        button5.clicked.connect(self.plot_series)
        button6 = QtGui.QPushButton('Pie Chart')
        button6.clicked.connect(self.Pie)
        button7 = QtGui.QPushButton('Clear Canvas')
        button7.clicked.connect(self.clear_canvas)
        sublayout2 = QtGui.QGridLayout()
        sublayout2.addWidget(label2, 0, 0)
        sublayout2.addWidget(button4, 1, 0)
        sublayout2.addWidget(button5, 1, 1)
        sublayout2.addWidget(button6, 2, 0)
        sublayout2.addWidget(button7, 2, 1)
        grid.addLayout(sublayout2, 2, 0, 1, 1)

        label3 = QtGui.QLabel('Supervised / UnSupervised Learning')
        label3.setFont(QtGui.QFont('Calibri', 11, QtGui.QFont.Bold))
        button7 = QtGui.QPushButton('Decision Tree Classifier')
        button7.resize(button7.sizeHint())
        button7.clicked.connect(self.classifier)
        self.connect(button7, SIGNAL('clicked()'), self.dc_tree_info)
        self.connect(self, SIGNAL('main2closed()'), self.clearDecision)
        self.button8 = QtGui.QPushButton('Clustering(KMean)')
        self.connect(self.button8, SIGNAL('clicked()'), self.clustering)
        self.connect(self, SIGNAL('main2closed()'), self.clearCluster)
        button9 = QtGui.QPushButton('Predictive Learning')
        self.connect(button9, SIGNAL('clicked()'), self.prediction)
        self.connect(self, SIGNAL('main2closed()'), self.pred_close)
        sublayout3 = QtGui.QVBoxLayout()
        sublayout3.addWidget(label3)
        sublayout3.addWidget(button7)
        sublayout3.addWidget(self.button8)
        sublayout3.addWidget(button9)
        grid.addLayout(sublayout3, 3, 0, 1, 1)

        verticalLine = QtGui.QFrame()
        verticalLine.setFrameStyle(QtGui.QFrame.VLine)
        verticalLine.setSizePolicy(QtGui.QSizePolicy.Minimum,
                                   QtGui.QSizePolicy.Expanding)
        grid.addWidget(verticalLine, 1, 1, 6, 1)
        self.figure = plt.figure(figsize=(15, 5))
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        grid.addWidget(self.canvas, 1, 2, 1, 2)
        grid.addWidget(self.toolbar, 0, 2, 1, 2)

        self.show()
Beispiel #15
0
    def initUI(self):
        self.setGeometry(600, 400, 750, 500)
        self.setWindowTitle('Task Manager')
        self.setFixedSize(1100, 550)

        self.grid = QtGui.QGridLayout()
        self.setLayout(self.grid)
        #self.proc_table()

        #aqui estaba tabla proc

        self.gtMemProcess = []
        self.gtCpuProcess = []
        #------------------------------Botones!------------------------------------------
        self.btnEliminar = QtGui.QPushButton('Matar', self)
        btnGrafCPU = QtGui.QPushButton('Ordenar CPU',
                                       self)  #############cambie de proc a cpu
        btnGrafMem = QtGui.QPushButton('Ordenar Memoria', self)
        btnOrden = QtGui.QPushButton('Ordenar PID', self)
        self.btnMapDisk = QtGui.QPushButton('Map Disk', self)
        self.btnBrrCache = QtGui.QPushButton('Borrar Cache', self)
        self.btnMapFolders = QtGui.QPushButton('Map Folders', self)
        self.btnpopup = QtGui.QPushButton('Traer al Frente', self)

        #<<<<<<< HEAD
        # self.btnEliminar.setFixedSize(75,75)  #Tamano de botones
        # btnGrafMem.setFixedSize(75,30)
        # btnGrafCPU.setFixedSize(75,30)
        # self.btnMapDisk.setFixedSize(155,30)
        # self.btnBrrCache.setFixedSize(75,30)
        #
        # self.btnEliminar.move(460,13)
        # btnGrafMem.move(540,280)
        # btnGrafCPU.move(460,280)
        # self.btnMapDisk.move(460,245)
        #=======
        self.btnEliminar.setFixedSize(155, 75)  #Tamano de botones
        btnOrden.setFixedSize(115, 75)
        btnGrafMem.setFixedSize(155, 37.5)
        btnGrafCPU.setFixedSize(155, 37.5)
        self.btnMapDisk.setFixedSize(155, 75)
        self.btnBrrCache.setFixedSize(115, 30)
        self.btnMapFolders.setFixedSize(115, 30)
        self.btnpopup.setFixedSize(115, 30)

        self.btnEliminar.move(115, 315)
        btnOrden.move(0, 315)
        btnGrafMem.move(425, 315)
        btnGrafCPU.move(425, 352.5)
        self.btnMapDisk.move(270, 315)
        self.btnBrrCache.move(0, 400)
        self.btnMapFolders.move(115, 400)
        self.btnpopup.move(230, 400)

        btnGrafMem.clicked.connect(self.ordenar_mem)
        btnGrafCPU.clicked.connect(self.ordenar_cpu)
        btnOrden.clicked.connect(self.ordenar_pid)
        self.btnEliminar.clicked.connect(self.Eliminar)
        self.btnpopup.clicked.connect(self.Popup)

        # ------------------------------Botones!------------------------------------------

        #Graficas
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
        self.grid.addWidget(self.canvas)
        #self.toolbar = NavigationToolbar(self.canvas,self)        ################esto que zoom and shit
        #=======
        self.canvas2 = FigureCanvas(self.figure)
        self.grid.addWidget(self.canvas, 0, 1)
        self.grid.addWidget(self.canvas2, 1, 1)
        #self.toolbar = NavigationToolbar(self.canvas,self)

        self.statusbar = QtGui.QStatusBar(self)
        self.grid.addWidget(self.statusbar)
        self.statusbar.showMessage("System Status | Normal")

        self.show()
Beispiel #16
0
    def __init__(self, parent, dirName):
        super(smileiQtPlot, self).__init__()
        self.setParent(parent)
        uiFile = os.path.dirname(
            os.path.realpath(__file__)) + '/smileiQtPlot.ui'
        self.ui = uic.loadUi(uiFile, self)

        self.dirName = dirName
        self.parent = parent

        self.parent.timer.timeout.connect(self.next)
        self.parent.ui.next.released.connect(self.next)
        self.parent.ui.previous.released.connect(self.previous)
        self.parent.ui.first.released.connect(self.first)
        self.parent.ui.last.released.connect(self.last)

        self.pauseSignal.connect(self.parent.pause)

        self.setWindowFlags(Qt.Window)
        self.setWindowTitle(dirName)

        self.step = 0

        self.ui.savePoints.setIcon(self.ui.style().standardIcon(
            QStyle.SP_DialogSaveButton))
        self.ui.savePoints.released.connect(self.doSavePoints)

        self.ui.tabWidget.currentChanged.connect(self.changeTab)
        self.ui.autoScale.stateChanged.connect(self.doPlots)

        self.fig = Figure()

        self.canvas = FigureCanvas(self.fig)
        self.canvas.setFocusPolicy(Qt.StrongFocus)
        self.canvas.setFocus()
        self.canvas.mpl_connect('motion_notify_event', self.on_movement)
        self.canvas.mpl_connect('key_press_event', self.on_key_press)
        self.canvas.mpl_connect('key_release_event', self.on_key_release)
        self.canvas.mpl_connect('button_press_event', self.on_button_press)

        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.setFixedHeight(18)
        self.canvas.setCursor(Qt.CrossCursor)

        self.ui.plotLayout.addWidget(self.canvas)
        self.ui.plotLayout.addWidget(self.toolbar)

        fname = os.path.join(dirName, "scalars.txt")
        if os.path.isfile(fname):
            self.scalarData = np.loadtxt(fname)
            names = []
            for line in open(fname):
                li = line.strip()
                if li.startswith("#"):
                    list = line.split()
                    names.append(list[-1])

            scalars_names = names[1:-2]
            for i in range(len(scalars_names)):
                my_button = QCheckBox(scalars_names[i])
                my_button.stateChanged.connect(self.checkBoxChanged)

                self.ui.layoutScalars.addWidget(my_button)

            self.ui.layoutScalars.addStretch()
        else:
            print "Problem reading ", fname
#             self.deleteLater()

        self.fieldSteps = []
        fname = os.path.join(dirName, "Fields.h5")
        if os.path.isfile(fname):

            self.fieldFile = tb.openFile(fname)
            self.res_space = self.fieldFile.root._v_attrs.res_space[0]
            self.res_time = self.fieldFile.root._v_attrs.res_time
            self.sim_length = self.fieldFile.root._v_attrs.sim_length
            self.fieldEvery = self.fieldFile.root._v_attrs.every

            first = True
            for group in self.fieldFile.listNodes("/", classname='Group'):
                self.fieldSteps.append(group._v_name)
                if first:
                    first = False
                    for array in group:
                        my_button = QCheckBox(array._v_name)
                        my_button.stateChanged.connect(self.checkBoxChanged)
                        self.ui.layoutFields.addWidget(my_button)

            self.ui.layoutFields.addStretch()
            self.ui.slider.setRange(0, len(self.fieldSteps) - 1)
        else:
            print "Problem reading ", fname
#             self.deleteLater()

        self.ui.spinStep.setSuffix("/" + str(len(self.fieldSteps) - 1))
        self.ui.spinStep.setMaximum(len(self.fieldSteps) - 1)

        fname = os.path.join(dirName, "PhaseSpace.h5")
        if os.path.isfile(fname):
            self.phaseFile = tb.openFile(fname)
            for phaseData in self.phaseFile.walkNodes("/", classname='Array'):
                my_button = QCheckBox(phaseData._v_pathname)
                my_button.stateChanged.connect(self.checkBoxChanged)
                self.ui.layoutPhase.addWidget(my_button)
            self.ui.layoutPhase.addStretch()
        else:
            print "Problem reading ", fname


#             self.deleteLater()

        self.load_settings()

        if sys.platform == "darwin":
            self.raise_()
        self.show()
Beispiel #17
0
 def __init__(self, parent=None):
     super(Ui_LboardWindow, self).__init__()
     self.figure = plt.figure(figsize=(50, 20), facecolor="white")  #
     self.canvas = FigureCanvas(
         self.figure)  #create canvas that will hold our plot
Beispiel #18
0
    def create_main_frame(self):
        self.main_frame = QWidget()

        # Create the mpl Figure and FigCanvas objects.
        # 5x4 inches, 100 dots-per-inch
        #
        self.dpi = 100
        self.fig = Figure((5.0, 4.0), dpi=self.dpi)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.main_frame)

        # Since we have only one plot, we can use add_axes
        # instead of add_subplot, but then the subplot
        # configuration tool in the navigation toolbar wouldn't
        # work.
        #
        self.axes = self.fig.add_subplot(111)

        # Bind the 'pick' event for clicking on one of the bars
        #
        self.canvas.mpl_connect('pick_event', self.on_pick)

        # Create the navigation toolbar, tied to the canvas
        #
        self.mpl_toolbar = NavigationToolbar(self.canvas, self.main_frame)

        # Other GUI controls
        #
        self.textbox = QLineEdit()
        self.textbox.setMinimumWidth(200)
        self.connect(self.textbox, SIGNAL('editingFinished ()'), self.on_draw)

        self.draw_button = QPushButton("&Draw")
        self.connect(self.draw_button, SIGNAL('clicked()'), self.on_draw)

        self.grid_cb = QCheckBox("Show &Grid")
        self.grid_cb.setChecked(False)
        self.connect(self.grid_cb, SIGNAL('stateChanged(int)'), self.on_draw)

        slider_label = QLabel('Bar width (%):')
        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(1, 100)
        self.slider.setValue(20)
        self.slider.setTracking(True)
        self.slider.setTickPosition(QSlider.TicksBothSides)
        self.connect(self.slider, SIGNAL('valueChanged(int)'), self.on_draw)

        #
        # Layout with box sizers
        #
        hbox = QHBoxLayout()

        for w in [
                self.textbox, self.draw_button, self.grid_cb, slider_label,
                self.slider
        ]:
            hbox.addWidget(w)
            hbox.setAlignment(w, Qt.AlignVCenter)

        vbox = QVBoxLayout()
        vbox.addWidget(self.canvas)
        vbox.addWidget(self.mpl_toolbar)
        vbox.addLayout(hbox)

        self.main_frame.setLayout(vbox)
        self.setCentralWidget(self.main_frame)
    def update(self, MainWindow):
        dataOk = 0
        global detObj
        rangeDoppler = [[]]
        rangeArray = []
        dopplerArray = []
        x = []
        y = []
        rangeVal = []
        dopplerVal = []
        peakVal = []

        # Read and parse the received data
        #configParameters = parseConfigFile(configFileName)

        dataOk, frameNumber, detObj, rangeDoppler, rangeArray, dopplerArray = readAndParseData16xx(
            self.port1)
        print(rangeDoppler)

        if dataOk and len(detObj["x"]) > 0:

            # print(detObj)

            scene = QGraphicsScene()
            scene1 = QGraphicsScene()
            self.Plot_BitFreq_Pow.setScene(scene)
            self.Plot_RangeDoppler.setScene(scene1)
            figure = Figure()
            figure1 = Figure()
            axes = figure.gca()
            axes1 = figure1.gca()

            for i in range(1600):
                try:

                    #configParameters = parseConfigFile(configFileName)
                    dataOk, frameNumber, detObj, rangeDoppler, rangeArray, dopplerArray = readAndParseData16xx(
                        self.port1)
                    longitud = detObj["x"]
                    lateral = -detObj["y"]
                    rangeVal = detObj["RangeXY"]
                    dopplerVal = detObj["dopplerVal"]
                    peakVal = detObj["peakVal"]
                    print(detObj["x"])

                    # lateral,longitud,peakVal,rangeVal,dopplerVal = filtrer(dopplerVal,rangeVal,peakVal,20,longitud,lateral)
                    # filtrage
                    Longitude = []
                    Laterale = []
                    Portee = []
                    Velocity = []
                    Power = []
                    for ii in range(len(rangeVal)):
                        if rangeVal[ii] <= 20:
                            Longitude.append(longitud[ii])
                            Laterale.append(lateral[ii])
                            Portee.append(rangeVal[ii])
                            Velocity.append(dopplerVal[ii])
                            Power.append(peakVal[ii])

                    axes1.set_title("Range Doppler")

                    axes.set_title("Plot X and Y")
                    axes.set_xlim(xmin=-20, xmax=20)
                    axes.set_ylim(ymin=0, ymax=20)
                    axes.set_xlabel('left', text='X Position (m)')
                    axes.set_ylabel('bottom', text='Y Position (m)')

                    #print(i)
                    if len(lateral) > 2:
                        plt.draw()
                        #plt.connect('motion_notify_event', mouse_move)
                        plt.pause(0.1)
                        axes.clear()
                        axes1.clear()
                        axes1.imshow(rangeDoppler,
                                     interpolation='nearest',
                                     aspect='auto',
                                     extent=[
                                         np.min(rangeArray),
                                         np.max(rangeArray),
                                         np.min(dopplerArray),
                                         -np.min(dopplerArray)
                                     ])
                        axes.scatter(Laterale,
                                     Longitude,
                                     c=Power,
                                     cmap=cm.rainbow)
                        datacursor(display='multiple', draggable=True)
                        canvas = FigureCanvas(figure)
                        canvas1 = FigureCanvas(figure1)
                        canvas.setGeometry(QRect(850, 390, 491, 291))
                        canvas1.setGeometry(QRect(850, 130, 491, 221))
                        scene.addWidget(canvas)
                        scene1.addWidget(canvas1)

                except BaseException:
                    print("File no Traitable!!!")

        return dataOk
    ax1.plot(Metricdata.trange, Metricdata.wavdata )

    ax2 = fig.add_subplot(3,2,2)
    ax2.plot(Metricdata.fscalek, Metricdata.AdftLog)

    ax3 = fig.add_subplot(3,2,3)
    ax3.plot(Metricdata.fscalek, Metricdata.dftSpc_env)

    ax4 = fig.add_subplot(3,2,4)
    ax4.plot(Metricdata.fscalek, Metricdata.dftSpc_det)
    pl.xlim(0, 2)

    ax5 = fig.add_subplot(3,2,5)

    # MatplotオブジェクトをPySide用Widgetに変換
    canvas = FigureCanvas(fig)

    # butoon
    # plot_button = QtGui.QPushButton("plot")
    # play_button = QtGui.QPushButton("play")
    #
    # slider1 = QtGui.QSlider(QtCore.Qt.Horizontal)
    # slider2 = QtGui.QSlider(QtCore.Qt.Horizontal)
    # slider3 = QtGui.QSlider(QtCore.Qt.Horizontal)
    # slider4 = QtGui.QSlider(QtCore.Qt.Horizontal)

    # set layout
    widget = QtGui.QWidget()
    layout = QtGui.QVBoxLayout()
    layout.addStretch(1)
    widget.setLayout(layout)
Beispiel #21
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        # Read data from source or leakage fraction file
        self.get_file_data()
        self.main_frame = QWidget()
        self.setCentralWidget(self.main_frame)

        # Create the Figure, Canvas, and Axes
        self.dpi = 100
        self.fig = Figure((5.0, 15.0), dpi=self.dpi)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.main_frame)
        self.axes = self.fig.add_subplot(111)

        # Create the navigation toolbar, tied to the canvas
        self.mpl_toolbar = NavigationToolbar(self.canvas, self.main_frame)

        # Grid layout at bottom
        self.grid = QGridLayout()

        # Overall layout
        self.vbox = QVBoxLayout()
        self.vbox.addWidget(self.canvas)
        self.vbox.addWidget(self.mpl_toolbar)
        self.vbox.addLayout(self.grid)
        self.main_frame.setLayout(self.vbox)

        # Tally selections
        label_tally = QLabel("Tally:")
        self.tally = QComboBox()
        self.tally.addItems([(str(i + 1)) for i in range(self.n_tallies)])
        self.connect(self.tally, SIGNAL('activated(int)'), self._update)
        self.connect(self.tally, SIGNAL('activated(int)'), self.populate_boxes)
        self.connect(self.tally, SIGNAL('activated(int)'), self.on_draw)

        # Planar basis
        label_basis = QLabel("Basis:")
        self.basis = QComboBox()
        self.basis.addItems(['xy', 'yz', 'xz'])

        # Update window when 'Basis' selection is changed
        self.connect(self.basis, SIGNAL('activated(int)'), self._update)
        self.connect(self.basis, SIGNAL('activated(int)'), self.populate_boxes)
        self.connect(self.basis, SIGNAL('activated(int)'), self.on_draw)

        # Axial level within selected basis
        label_axial_level = QLabel("Axial Level:")
        self.axial_level = QComboBox()
        self.connect(self.axial_level, SIGNAL('activated(int)'), self.on_draw)

        # Add Option to plot mean or uncertainty
        label_mean = QLabel("Mean or Uncertainty:")
        self.mean = QComboBox()
        self.mean.addItems(
            ['Mean', 'Absolute Uncertainty', 'Relative Uncertainty'])

        # Update window when mean selection is changed
        self.connect(self.mean, SIGNAL('activated(int)'), self.on_draw)

        self.label_filters = QLabel("Filter options:")

        # Labels for all possible filters
        self.labels = {
            'cell': 'Cell: ',
            'cellborn': 'Cell born: ',
            'surface': 'Surface: ',
            'material': 'Material',
            'universe': 'Universe: ',
            'energyin': 'Energy in: ',
            'energyout': 'Energy out: '
        }

        # Empty reusable labels
        self.qlabels = {}
        for j in range(8):
            self.nextLabel = QLabel
            self.qlabels[j] = self.nextLabel

        # Reusable comboboxes labelled with filter names
        self.boxes = {}
        for key in self.labels.keys():
            self.nextBox = QComboBox()
            self.connect(self.nextBox, SIGNAL('activated(int)'), self.on_draw)
            self.boxes[key] = self.nextBox

        # Combobox to select among scores
        self.score_label = QLabel("Score:")
        self.scoreBox = QComboBox()
        for item in self.tally_scores[0]:
            self.scoreBox.addItems(str(item))
        self.connect(self.scoreBox, SIGNAL('activated(int)'), self.on_draw)

        # Fill layout
        self.grid.addWidget(label_tally, 0, 0)
        self.grid.addWidget(self.tally, 0, 1)
        self.grid.addWidget(label_basis, 1, 0)
        self.grid.addWidget(self.basis, 1, 1)
        self.grid.addWidget(label_axial_level, 2, 0)
        self.grid.addWidget(self.axial_level, 2, 1)
        self.grid.addWidget(label_mean, 3, 0)
        self.grid.addWidget(self.mean, 3, 1)
        self.grid.addWidget(self.label_filters, 4, 0)

        self._update()
        self.populate_boxes()
        self.on_draw()
Beispiel #22
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.setMinimumSize(QSize(900, 500))
        # Create the mpl Figure and FigCanvas objects.
        # 5x4 inches, 100 dots-per-inch
        #
        self.setWindowFlags(Qt.WindowMinimizeButtonHint
                            | Qt.WindowMaximizeButtonHint)
        self.new_obj = None
        self.project = None
        self.dpi = 100
        self.fig = Figure((5.0, 4.5), dpi=self.dpi)
        self.canvas = FigureCanvas(self.fig)
        # Since we have only one plot, we can use add_axes
        # instead of add_subplot, but then the subplot
        # configuration tool in the navigation toolbar wouldn't
        # work.
        #
        self.axes = self.fig.add_subplot(111)

        self.addfilter = QWidget(self)
        addfilterlayout = QGridLayout()
        self.addfilter.setLayout(addfilterlayout)

        filter = QGroupBox(self)
        addfilter = QGridLayout()
        filter.setLayout(addfilter)
        var1 = QLabel("Variable 1")
        self.choicevar1 = QComboBox()
        self.choicevar1.setMinimumWidth(200)
        self.selectvar2 = QCheckBox("Check to enable variable 2")
        var2 = QLabel("Variable 2")
        self.choicevar2 = QComboBox()
        self.choicevar2.setMinimumWidth(200)
        self.choicevar2.setEnabled(False)
        addfilter.addWidget(var1, 0, 0)
        addfilter.addWidget(var2, 1, 0)
        addfilter.addWidget(self.choicevar1, 0, 1)
        addfilter.addWidget(self.selectvar2, 0, 2)
        addfilter.addWidget(self.choicevar2, 1, 1)
        addfilterlayout.addWidget(filter, 0, 0)

        #        segment = QGroupBox(self)
        #        addsegment = QGridLayout()
        #        segment.setLayout(addsegment)
        #        self.segment1 = QRadioButton("Adult Worker")
        #        self.segment2 = QRadioButton("Adult Non-worker")
        #        self.segment3 = QRadioButton("Non-adult (5-17)")
        #        self.segment4 = QRadioButton("Preschool (0-4)")
        #        addsegment.addWidget(self.segment1,0,0)
        #        addsegment.addWidget(self.segment2,0,1)
        #        addsegment.addWidget(self.segment3,1,0)
        #        addsegment.addWidget(self.segment4,1,1)
        #        addfilterlayout.addWidget(segment,0,1)

        addfilterlayout.setColumnStretch(0, 3)
        addfilterlayout.setColumnStretch(1, 2)

        self.vbox = QVBoxLayout()
        self.vbox.setStretch(0, 1)
        self.dialogButtonBox = QDialogButtonBox(QDialogButtonBox.Ok)

        #self.connect(self.dialogButtonBox, SIGNAL("accepted()"), self, SLOT("accept()"))
        #self.connect(self, SIGNAL('triggered()'),self.closeEvent)
        self.connect(self.dialogButtonBox, SIGNAL("accepted()"),
                     self.disconnects)
Beispiel #23
0
 def addmpl(self, fig):
     self.canvas = FigureCanvas(fig)
     self.plotADC.addWidget(self.canvas)
     self.canvas.draw()
     self.toolbar = NavigationToolbar(self.canvas, self, coordinates=True)
     self.plotADC.addWidget(self.toolbar)
Beispiel #24
0
 def addmpl(self, fig):
     self.canvas = FigureCanvas(fig)
     self.device_container.addWidget(self.canvas)
     self.canvas.draw()
Beispiel #25
0
    def __init__(self, parent=None):
        super(mainWindow, self).__init__(parent)

        ## ---------------------- TAB 1--------------------------------------

        self.timer = QTimer()
        self.timer.timeout.connect(self.tick)
        self.timer.start(1000)

        self.RunPlots = False
        self.NoOfPlots = 8
        self.PlotNo = {}
        self.unitNo = {}
        self.comboColor2 = {}
        self.comboStyle2 = {}
        self.sensorData = {}
        self.checkboxShow = {}
        self.comboCOMport = 1
        self.comboBaudRate = 9600
        self.filled = {}

        self.time_var = 0
        self.data1_arr = []

        self.plotColor = ['k', 'k', 'b', 'r', 'y', 'g', 'b', 'r', 'y', 'g']
        self.plotStyle = ['-', '-', '-', '-', '-', '-', '-', '-', '-', '-']
        self.usePlot = ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1']

        # Tab 1
        self.tab1 = QtGui.QWidget()
        self.addTab(self.tab1, "Incomming Data")

        self.figure = plt.figure(figsize=(30, 15))
        self.resize(1200, 700)
        self.canvas = FigureCanvas(self.figure)

        # Label
        l1 = QLabel()
        l2 = QLabel()
        l3 = QLabel()
        l4 = QLabel()
        l5 = QLabel()
        l6 = QLabel()
        l7 = QLabel()

        l1.setText("Show")
        l2.setText("Unit No")
        l3.setText("Data")
        l4.setText("Plot No")
        l5.setText("Offset")
        l6.setText("Plot Color")
        l7.setText("Plot Style")

        l1.setAlignment(Qt.AlignLeft)
        l2.setAlignment(Qt.AlignLeft)
        l3.setAlignment(Qt.AlignLeft)
        l4.setAlignment(Qt.AlignLeft)
        l5.setAlignment(Qt.AlignLeft)
        l6.setAlignment(Qt.AlignLeft)
        l7.setAlignment(Qt.AlignLeft)

        ## Create Grid for
        grid = QGridLayout()

        grid.addWidget(l1, 1, 1)
        grid.addWidget(l2, 1, 2)
        grid.addWidget(l3, 1, 3)
        grid.addWidget(l4, 1, 4)
        grid.addWidget(l5, 1, 5)
        grid.addWidget(l6, 1, 6)
        grid.addWidget(l7, 1, 7)

        for i in range(2, self.NoOfPlots + 1):
            # Checkboxes
            self.checkboxShow[i] = QtGui.QCheckBox('', self)
            self.checkboxShow[i].setChecked(True)

            # Combo box 1 - Plot nr
            self.PlotNo[i] = QtGui.QComboBox(self)
            self.PlotNo[i].addItem("1")
            self.PlotNo[i].addItem("2")
            self.PlotNo[i].setFixedWidth(50)

            # Combo box 2 - Slave nr
            self.unitNo[i] = QtGui.QComboBox(self)
            self.unitNo[i].addItem("1")
            self.unitNo[i].addItem("2")
            self.unitNo[i].addItem("3")
            self.unitNo[i].addItem("4")
            self.unitNo[i].addItem("5")
            self.unitNo[i].addItem("6")
            self.unitNo[i].addItem("7")
            self.unitNo[i].setFixedWidth(50)

            # Combo box 3 - Sensor Data
            self.sensorData[i] = QtGui.QComboBox(self)
            self.sensorData[i].addItem("Temperature 1")
            self.sensorData[i].addItem("Temperature 2")
            self.sensorData[i].addItem("Temperature 3")
            self.sensorData[i].addItem("Humidity 1")
            self.sensorData[i].addItem("Light 1")
            self.sensorData[i].setFixedWidth(150)

            # Offset
            line = QtGui.QLineEdit(self)
            line.setFixedWidth(50)

            # Plot Color
            colorPath = "C:/Users/KWFO/Desktop/Python_GUI/plot_colors/"
            self.comboColor2[i] = QtGui.QComboBox(self)
            self.comboColor2[i].addItem(QIcon(colorPath + "black.png"), "")
            self.comboColor2[i].addItem(QIcon(colorPath + "blue.png"), "")
            self.comboColor2[i].addItem(QIcon(colorPath + "red1.png"), "")
            #self.comboColor2[i].addItem(QIcon(colorPath + "yellow1.png"),"")
            self.comboColor2[i].addItem(QIcon(colorPath + "green.png"), "")
            self.comboColor2[i].addItem(QIcon(colorPath + "orange.png"), "")
            self.comboColor2[i].addItem(QIcon(colorPath + "magenta.png"), "")
            self.comboColor2[i].addItem(QIcon(colorPath + "cyan2.png"), "")
            self.comboColor2[i].setFixedWidth(50)
            self.comboColor2[i].setCurrentIndex(
                i - 2)  # Set different color for all at startup

            # Plot Style
            self.comboStyle2[i] = QtGui.QComboBox(self)
            self.comboStyle2[i].addItem("solid")
            self.comboStyle2[i].addItem("dashed")
            self.comboStyle2[i].addItem("dots")
            self.comboStyle2[i].addItem("solid + dots")
            self.comboStyle2[i].setFixedWidth(90)

            grid.addWidget(self.checkboxShow[i], i, 1)
            grid.addWidget(self.unitNo[i], i, 2)
            grid.addWidget(self.sensorData[i], i, 3)
            grid.addWidget(self.PlotNo[i], i, 4)
            grid.addWidget(line, i, 5)
            grid.addWidget(self.comboColor2[i], i, 6)
            grid.addWidget(self.comboStyle2[i], i, 7)

        b1 = QPushButton("Plot incomming data")
        b1.clicked.connect(self.b1_clicked)
        b1.setFixedHeight(40)
        b1.setFixedWidth(125)

        b2 = QPushButton("Stop plotting")
        b2.clicked.connect(self.b2_clicked)
        b2.setFixedHeight(40)
        b2.setFixedWidth(125)

        serial_Setup = QGridLayout()
        com_port = QLabel()
        com_port.setText("COM Port")
        baudrate = QLabel()
        baudrate.setText("Baud Rate")
        self.comboCOMport = QtGui.QComboBox(self)
        self.comboCOMport.addItem("COM1")
        self.comboCOMport.addItem("COM2")
        self.comboCOMport.addItem("COM3")
        self.comboCOMport.addItem("COM4")
        self.comboCOMport.addItem("COM5")
        self.comboCOMport.addItem("COM6")
        self.comboCOMport.addItem("COM7")
        self.comboCOMport.addItem("COM8")
        self.comboCOMport.addItem("COM9")
        self.comboBaudRate = QtGui.QComboBox(self)
        self.comboBaudRate.addItem("9600")
        self.comboBaudRate.addItem("18200")
        self.comboBaudRate.addItem("36400")
        self.comboBaudRate.addItem("72800")
        self.comboBaudRate.addItem("115600")
        serial_Setup.addWidget(com_port, 1, 1)
        serial_Setup.addWidget(self.comboCOMport, 2, 1)
        serial_Setup.addWidget(baudrate, 1, 2)
        serial_Setup.addWidget(self.comboBaudRate, 2, 2)

        buttons = QtGui.QHBoxLayout()
        buttons.addWidget(b1)
        buttons.addWidget(b2)
        buttons.addSpacing(100)
        buttons.addLayout(serial_Setup)
        buttons.addStretch()

        self.show_plot_1 = QtGui.QCheckBox('Show Plot 1', self)
        self.show_plot_1.setChecked(True)
        self.show_plot_2 = QtGui.QCheckBox('Show Plot 2', self)
        self.show_plot_2.setChecked(True)

        # Input Data on Left Side Of Screen
        input_data = QtGui.QVBoxLayout()
        input_data.addLayout(buttons)
        input_data.addSpacing(20)
        input_data.addWidget(self.show_plot_1)
        input_data.addWidget(self.show_plot_2)
        input_data.addSpacing(40)
        input_data.addLayout(grid)
        input_data.addStretch()

        hbox = QtGui.QHBoxLayout()
        hbox.addLayout(input_data)
        hbox.addWidget(self.canvas)

        self.tab1.setLayout(hbox)
        ## ---------------------------------------------------

        # Tab 2
        self.txt_data = {}
        self.txt_data2 = {}
        self.unit_1 = {}
        self.unit_2 = {}
        #self.lineEdit = ''

        self.tab2 = QtGui.QWidget()
        self.addTab(self.tab2, "Load Saved Data")

        buttonLoadData = QPushButton("Load Data")
        buttonLoadData.clicked.connect(self.loadData_clicked)
        buttonLoadData.setFixedHeight(40)
        buttonLoadData.setFixedWidth(125)

        self.figure2 = plt.figure(figsize=(30, 15))
        self.canvas2 = FigureCanvas(self.figure2)

        tab2_hbox = QtGui.QHBoxLayout()
        tab2_hbox.addWidget(buttonLoadData)
        tab2_hbox.addWidget(self.canvas2)

        self.tab2.setLayout(tab2_hbox)

        # --------------Tab 3
        self.tab3 = QtGui.QWidget()
        self.addTab(self.tab3, "Tab3 Test")

        btnLoadData = QPushButton("Load Data")
        btnLoadData.clicked.connect(self.loadData_clicked)
        btnLoadData.setFixedHeight(40)
        btnLoadData.setFixedWidth(125)

        load_table = QTableWidget()
        load_table.setWindowTitle("Loaded Data")
        #load_table.resize(800, 800)
        load_table.setRowCount(5)
        load_table.setColumnCount(2)

        view_table = QTableWidget()
        view_table.setWindowTitle("Data to View")
        #view_table.resize(800, 800)
        view_table.setRowCount(5)
        view_table.setColumnCount(2)

        table_hbox = QtGui.QHBoxLayout()
        table_hbox.addWidget(load_table)
        table_hbox.addSpacing(50)
        table_hbox.addWidget(view_table)

        myData = DataClass(6)
        myObj = ActionClass(self.tab3, myData)

        input_data2 = QtGui.QVBoxLayout()
        input_data2.addWidget(btnLoadData)
        input_data2.addLayout(myObj.grid)
        input_data2.addLayout(table_hbox)
        input_data2.addStretch()

        self.figure3 = plt.figure(figsize=(30, 15))
        self.canvas3 = FigureCanvas(self.figure3)

        tab3_hbox = QtGui.QHBoxLayout()
        tab3_hbox.addLayout(input_data2)
        tab3_hbox.addWidget(self.canvas3)

        self.tab3.setLayout(tab3_hbox)

        # Plot example
        tab3_data = [1, 2, 3, 4, 6, 8]
        self.figure3.clf()
        tab3_ax = self.figure3.add_subplot(111)
        tab3_ax.plot(tab3_data, '--', color='blue')

        self.canvas2.draw()

        # Plot First Time
        self.plot()
Beispiel #26
0
    def __init__(self, sampleinterval=.01, timewindow=10.):
        self._interval = int(sampleinterval * 1000)

        ## Always start by initializing Qt (only once per application)
        self.app = QApplication(sys.argv)
        #self.setQuitOnLastWindowClosed(False)

        ## Define a top-level widget to hold everything
        self.w_pane = QWidget()
        self.w_pane.setGeometry(300, 300, 1200, 700)

        ## Create some widgets to be placed inside
        self.w_pane.setWindowTitle('ASL Learner')
        self.left_box = QWidget(self.w_pane)
        self.label_pic = QLabel(self.left_box)
        #self.listwidget = QListWidget()
        #self.listwidget.maximumSize(50,100)
        self.left_frame = QFrame(self.w_pane)
        #self.left_frame.setMinimumWidth(50)
        #self.left_frame.setMaximumWidth(100)
        self.label = QLabel(self.w_pane)
        self.fig = Figure((10, 8))
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.w_pane)
        self.canvas.setFocusPolicy(Qt.StrongFocus)
        self.canvas.setFocus()

        ## Create a grid layout to manage the widgets size and position
        self.layout = QGridLayout()
        self.layout_box = QVBoxLayout()
        #self.layout.setColumnMaxWidth(0, 50)
        #
        ## Set pics
        self.hand_over = QPixmap(
            "C:/Users/Tetris/Desktop/HCI 2016/images/leaphoverbest.png")
        self.hand_over = self.hand_over.scaledToHeight(400)
        self.thumbs_up = QPixmap(
            "C:/Users/Tetris/Desktop/HCI 2016/images/thumbsup.png")
        self.thumbs_up = self.thumbs_up.scaledToHeight(200)
        self.label.setPixmap(self.hand_over)
        self.hand_color = 'r'

        ## Add widgets to the layout in their proper positions
        self.layout_box.addWidget(self.label_pic)
        self.layout.addWidget(self.left_box, 1, 0, 1,
                              1)  # list widget goes in bottom-left
        self.layout.addWidget(self.canvas, 0, 1, 5,
                              20)  # plot goes on right side, spanning 3 rows
        self.layout.addWidget(self.label, 0, 1, 5,
                              20)  # plot goes on right side, spanning 3 rows
        #self.layout.addWidget(self.label,0,0)

        ## Display the widget as a new window
        self.w_pane.setLayout(self.layout)
        self.left_box.setLayout(self.layout_box)
        self.left_box.show()
        self.w_pane.show()

        #Initialize Leap
        self.controller = Leap.Controller()
        self.clf = pickle.load(
            open(
                'C:/Users/Tetris/Desktop/HCI 2016/Deliverable 7/userData/classifier.p',
                'r'))
        self.predictedNumArray = []

        # QTimer
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.updateplot)
        self.timer.start(self._interval)
        self.lines = []
        self.on_draw()
Beispiel #27
0
    def initUI(self):

        """Initialise GUI."""

        # Initialise objects and widgets
        self.data = Data()
        self.load_button = LoadButton()
        self.trace_list = TimeSeriesList()
        self.trace_list.list.setMaximumWidth(250)
        self.remove_button = QtGui.QPushButton("Remove", self)
        self.time_axis_button = QtGui.QPushButton("Set time axis", self)
        self.average_button = QtGui.QPushButton("Time average", self)
        self.average_button.setEnabled(False)
        self.sep_axes_button = QtGui.QPushButton("Multiple axes", self)
        self.sep_axes_button.setCheckable(True)
        self.sep_axes_button.setDefault(False) # stop auto highlighting
        self.sep_axes_button.setAutoDefault(False)
        self.legend_button = QtGui.QPushButton("Legend", self)
        self.legend_button.setCheckable(True)
        self.legend_button.setDefault(False) # stop auto highlighting
        self.legend_button.setAutoDefault(False)
        self.reset_button = QtGui.QPushButton("Undo changes", self)
        self.nan_mode_button = QtGui.QPushButton("NaN mode", self)
        self.nan_mode_button.setCheckable(True)
        self.NaN_button = QtGui.QPushButton("NaN", self)
        self.NaN_button.setEnabled(False)
        self.normalise_button = QtGui.QPushButton("Normalise", self)
        self.normalise_button.setCheckable(True)
        self.normalise_text_field = QtGui.QLineEdit()
        self.bg_mode_button = QtGui.QPushButton("Background mode", self)
        self.bg_mode_button.setCheckable(True)
        self.get_bg_val_button = QtGui.QPushButton("Get Background", self)
        self.get_bg_val_button.setEnabled(False) # default is off
        self.bg_text_field = QtGui.QLineEdit()
        self.bg_text_field.setEnabled(False) # default is off
        self.set_bg_val_button = QtGui.QPushButton("Set background", self)
        self.set_bg_val_button.setEnabled(False) # default is off
        self.cal_mode_button = QtGui.QPushButton("Calibrate mode", self)
        self.cal_mode_button.setCheckable(True)
        self.cal_text_field = QtGui.QLineEdit()
        self.cal_text_field.setEnabled(False) # default is off
        self.set_cal_val_button = QtGui.QPushButton("Calibrate", self)
        self.set_cal_val_button.setEnabled(False) # default is off
        self.figure = mpl.figure.Figure()
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.stats_box = QtGui.QTextEdit()
        self.stats_box.setReadOnly(True)
        self.stats_box.setMaximumWidth(350)
        self.message_window = MessageWindow()
        self.message_window.window.setMaximumWidth(350)
        self.export_button = ExportButton()
        self.export_button.button.setEnabled(False) # default is off
        

        # Bindings
        self.load_button.dataLoaded.connect(self.readData) #read data into object
        self.time_axis_button.pressed.connect(self.SetTimeAxis) # set the time axis for the data
        self.sep_axes_button.pressed.connect(self.SeparateAxes) # multiplot button
        self.legend_button.pressed.connect(self.ToggleLegend) # multiplot button
        self.average_button.pressed.connect(self.AverageUp)
        self.remove_button.pressed.connect(self.RemoveColumn) # delete dataframe column
        self.trace_list.list.itemSelectionChanged.connect(self.DisplayData) # plot different data
        self.trace_list.list.itemSelectionChanged.connect(lambda nto=False : self.SetNormalise(nto)) # toggle normalise widget
        self.trace_list.list.itemSelectionChanged.connect(self.ReadMessages) # plot different data
        self.trace_list.list.itemSelectionChanged.connect(self.Toggle_bg_functionality)
        self.trace_list.list.itemSelectionChanged.connect(self.GetStats)
        self.trace_list.list.itemChanged.connect(self.Rename) # rename dataframe column
        self.nan_mode_button.pressed.connect(self.NanMode) # activate nan mode
        self.NaN_button.released.connect(self.Nan_points) # Execute the NaN
        self.bg_mode_button.pressed.connect(self.BgMode) # activate bg mode
        self.get_bg_val_button.pressed.connect(self.GetBg) # get background value
        self.set_bg_val_button.pressed.connect(self.SetBg) # get background value
        self.reset_button.pressed.connect(self.ResetDF) # reset dataframe
        self.normalise_button.pressed.connect(lambda nto=True : self.SetNormalise(nto)) # normalise trace
        self.cal_mode_button.pressed.connect(self.CalMode) # activate bg mode
        self.set_cal_val_button.pressed.connect(self.SetCalibrate) # calibrate
        self.export_button.button.pressed.connect(self.saveData) # Export data

        # Layout


        # action = QtGui.QAction("do something", self)
        # def p(self):
        #     print "text"
        # action.triggered.connect(p)

        self.load_vbox = QtGui.QVBoxLayout()
        self.load_vbox.addWidget(self.load_button.button)
        self.load_vbox.addWidget(self.trace_list.list)
        self.load_vbox.addWidget(self.remove_button)
        self.plotoptions_hbox = QtGui.QHBoxLayout()
        self.plotoptions_hbox.addWidget(self.time_axis_button)
        self.plotoptions_hbox.addWidget(self.average_button)
        self.plotoptions_hbox.addWidget(self.sep_axes_button)
        self.plotoptions_hbox.addWidget(self.legend_button)
        self.plotoptions_hbox.addWidget(self.reset_button)
        self.nan_hbox = QtGui.QHBoxLayout()
        self.nan_hbox.addWidget(self.nan_mode_button)
        self.nan_hbox.addWidget(self.NaN_button)
        self.bg_hbox = QtGui.QHBoxLayout()
        self.bg_hbox.addWidget(self.bg_mode_button)
        self.bg_hbox.addWidget(self.get_bg_val_button)
        self.bg_hbox.addWidget(self.bg_text_field)
        self.bg_hbox.addWidget(self.set_bg_val_button)
        self.normalise_hbox = QtGui.QHBoxLayout()
        self.normalise_hbox.addWidget(self.normalise_button)
        self.normalise_hbox.addWidget(self.normalise_text_field)
        self.calibrate_hbox = QtGui.QHBoxLayout()
        self.calibrate_hbox.addWidget(self.cal_mode_button)
        self.calibrate_hbox.addWidget(self.cal_text_field)
        self.calibrate_hbox.addWidget(self.set_cal_val_button)
        self.plot_vbox = QtGui.QVBoxLayout()
        self.plot_vbox.addWidget(self.canvas)
        self.plot_vbox.addWidget(self.toolbar)
        self.plot_vbox.addLayout(self.plotoptions_hbox)
        self.plot_vbox.addLayout(self.nan_hbox)
        self.plot_vbox.addLayout(self.bg_hbox)
        self.plot_vbox.addLayout(self.normalise_hbox)
        self.plot_vbox.addLayout(self.calibrate_hbox)
        self.output_vbox = QtGui.QVBoxLayout()
        self.output_vbox.addWidget(self.stats_box)
        self.output_vbox.addWidget(self.message_window.window)
        self.output_vbox.addWidget(self.export_button.button)
        self.main_hbox = QtGui.QHBoxLayout()
        self.main_hbox.addLayout(self.load_vbox)
        self.main_hbox.addLayout(self.plot_vbox)
        self.main_hbox.addLayout(self.output_vbox)
        self.setLayout(self.main_hbox)
        self.setGeometry(50, 50, 1200, 600)
        self.setWindowTitle('Time Series Cleaner')
        self.show()
Beispiel #28
0
    def __init__(self, logger):
        super(FitsViewer, self).__init__()
        self.logger = logger

        menubar = self.menuBar()

        # create a File pulldown menu, and add it to the menu bar
        filemenu = menubar.addMenu("File")

        item = QtGui.QAction("Open File", menubar)
        item.triggered.connect(self.open_file)
        filemenu.addAction(item)

        sep = QtGui.QAction(menubar)
        sep.setSeparator(True)
        filemenu.addAction(sep)

        item = QtGui.QAction("Quit", menubar)
        item.triggered.connect(self.close)
        filemenu.addAction(item)

        # Add matplotlib color maps to our built in ones
        cmap.add_matplotlib_cmaps()
        self.cmaps = cmap.get_names()
        self.imaps = imap.get_names()

        wd, ht = 500, 500

        # Create a Ginga widget
        fi = ImageViewCanvas(logger, render='widget')
        fi.enable_autocuts('on')
        fi.set_autocut_params('zscale')
        fi.enable_autozoom('on')
        fi.enable_draw(False)
        fi.set_callback('drag-drop', self.drop_file_cb)
        fi.set_callback('cursor-changed', self.cursor_cb)
        fi.set_bg(0.2, 0.2, 0.2)
        fi.ui_set_active(True)
        self.fitsimage = fi

        fi.show_color_bar(True)

        # enable various key and mouse controlled actions
        bd = fi.get_bindings()
        bd.enable_all(True)

        self.cp_tag = 'compass'

        # pack widget into layout
        gingaw = fi.get_widget()
        gingaw.resize(wd, ht)

        vbox1 = QtGui.QWidget()
        layout = QtGui.QVBoxLayout()
        layout.addWidget(gingaw, stretch=1)

        self.cm = cmap.get_cmap('gray')
        self.im = imap.get_imap('ramp')

        # color map selection widget
        wcmap = QtGui.QComboBox()
        for name in self.cmaps:
            wcmap.addItem(name)
        index = self.cmaps.index('gray')
        wcmap.setCurrentIndex(index)
        wcmap.activated.connect(self.set_cmap_cb)
        self.wcmap = wcmap

        # intensity map selection widget
        wimap = QtGui.QComboBox()
        for name in self.imaps:
            wimap.addItem(name)
        index = self.imaps.index('ramp')
        wimap.setCurrentIndex(index)
        wimap.activated.connect(self.set_cmap_cb)
        self.wimap = wimap

        #wopen = QtGui.QPushButton("Open File")
        #wopen.clicked.connect(self.open_file)

        # add buttons to layout
        hbox = QtGui.QHBoxLayout()
        hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2))
        hbox.addStretch(1)
        for w in (wcmap, wimap):
            hbox.addWidget(w, stretch=0)

        hw = QtGui.QWidget()
        hw.setLayout(hbox)
        layout.addWidget(hw, stretch=0)
        vbox1.setLayout(layout)

        # Create a matplotlib Figure
        #self.fig = matplotlib.figure.Figure(figsize=(wd, ht))
        self.fig = matplotlib.figure.Figure()
        self.canvas = FigureCanvas(self.fig)

        vbox2 = QtGui.QWidget()
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.canvas, stretch=1)

        # Add matplotlib buttons
        hbox = QtGui.QHBoxLayout()
        hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2))

        wgetimg = QtGui.QPushButton("Get Data")
        wgetimg.clicked.connect(self.get_image)
        wgetrgb = QtGui.QPushButton("Get RGB")
        wgetrgb.clicked.connect(self.get_rgb_image)
        #wquit = QtGui.QPushButton("Quit")
        #wquit.clicked.connect(self.close)

        hbox.addStretch(1)
        for w in (wgetimg, wgetrgb):
            hbox.addWidget(w, stretch=0)

        hw = QtGui.QWidget()
        hw.setLayout(hbox)
        layout.addWidget(hw, stretch=0)
        vbox2.setLayout(layout)

        vbox = QtGui.QVBoxLayout()
        vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2))
        vbox.setSpacing(1)

        w = QtGui.QWidget()
        layout = QtGui.QHBoxLayout()
        layout.addWidget(vbox1, stretch=1.0)
        layout.addWidget(vbox2, stretch=1.0)
        w.setLayout(layout)

        vbox.addWidget(w, stretch=1)

        self.readout = QtGui.QLabel("")
        vbox.addWidget(self.readout,
                       stretch=0,
                       alignment=QtCore.Qt.AlignCenter)

        vw = QtGui.QWidget()
        vw.setLayout(vbox)
        self.setCentralWidget(vw)
Beispiel #29
0
    def __init__(self):
        """
        This class creates the display window that is used by users to analyze their data

        Parameters
        ----------
        self

        Returns
        -------
        None
        """
        # This is just setting up some of the beginning variables
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle('XPD View')
        self.analysis_type = None
        self.file_path = None
        data_list, self.key_list = data_gen(1)
        self.int_key_list = []
        self.Tif = TifFileFinder()
        self.Azi = Azimuthal()
        self.surface = True
        self.three_dim_drawn = False
        self.int_data_dict = dict()

        self.setDockNestingEnabled(True)
        self.setAnimated(True)

        # This sets up all we need from the cross section 2D messenger class for use in the code
        self.messenger = CrossSection2DMessenger(data_list=data_list,
                                                 key_list=self.key_list)
        self.display = self.messenger._display
        self.ctrls = self.messenger._ctrl_widget
        self.ctrls.set_image_intensity_behavior('full range')
        self.messenger.sl_update_image(0)
        self.data_dict = self.messenger._view._data_dict

        # These lists will contain references to the pop up plots so that they can be updated
        self.rpp_list = list()
        self.three_dim_list = list()
        self.peak_plots = list()

        self.func_dict = {
            np.std.__name__: np.std,
            np.mean.__name__: np.mean,
            np.amin.__name__: np.amin,
            np.amax.__name__: np.amax,
            np.sum.__name__: np.sum
        }
        self.setDockNestingEnabled(True)
        self.setAnimated(True)

        # setting up dockable windows
        self.plot_dock = QtGui.QDockWidget("Dockable", self)
        self.plot_dock.setFeatures(QtGui.QDockWidget.DockWidgetFloatable
                                   | QtGui.QDockWidget.DockWidgetMovable)
        self.plot_dock.setWindowTitle("Reduced Representation")

        self.img_dock = QtGui.QDockWidget("Dockable", self)
        self.img_dock.setFeatures(QtGui.QDockWidget.DockWidgetFloatable
                                  | QtGui.QDockWidget.DockWidgetMovable)
        self.img_dock.setWindowTitle("Image")

        self.integration_dock = QtGui.QDockWidget("Dockable", self)
        self.integration_dock.setFeatures(
            QtGui.QDockWidget.DockWidgetFloatable
            | QtGui.QDockWidget.DockWidgetMovable)
        self.integration_dock.setWindowTitle("Integration")

        self.waterfall_dock = QtGui.QDockWidget("Dockable", self)
        self.waterfall_dock.setFeatures(QtGui.QDockWidget.DockWidgetFloatable
                                        | QtGui.QDockWidget.DockWidgetMovable)
        self.waterfall_dock.setWindowTitle("Waterfall Plot")

        self.is_main_rpp_plotted = False

        # This creates the canvases that all plots within the GUI will be drawn on
        self.fig3 = plt.figure()
        self.canvas3 = FigureCanvas(self.fig3)
        self.fig4 = plt.figure()
        self.canvas4 = FigureCanvas(self.fig4)

        # This creates the widgets so they can be accessed later
        self.name_label = QtGui.QLabel()
        self.img_slider = self.ctrls._slider_img
        self.img_spin = self.ctrls._spin_img
        self.color = self.ctrls._cm_cb
        self.int_style = self.ctrls._cmbbox_intensity_behavior
        self.int_min = self.ctrls._spin_min
        self.int_max = self.ctrls._spin_max

        # These statements add the dock widgets to the GUI
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.img_dock)
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.plot_dock)
        self.addDockWidget(QtCore.Qt.BottomDockWidgetArea,
                           self.integration_dock)
        self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.waterfall_dock)

        # These methods will set up the menu bars and the tool bars
        self.tools_box = QtGui.QToolBar()
        self.addToolBar(QtCore.Qt.BottomToolBarArea, self.tools_box)
        self.set_up_tool_bar()
        self.set_up_menu_bar()

        # These methods begin the process of creating the four tiles to hold the plots
        self.img_dock.setWidget(self.display)
        self.rpp = None
        self.one_dim_plot = None
        self.water = None
        self.r_rep_widget()
        self.one_dim_integrate()
        self.waterfall_2d()
Beispiel #30
0
    def initUI(self):
        self.figure = Figure()
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.lbSaveFolder = QtGui.QLabel("Save Folder :")
        self.lbSaveFolder.setFixedWidth(100)
        self.btnSaveFolder = QtGui.QPushButton('Search')
        self.btnSaveFolder.setFixedWidth(100)
        self.btnSaveFolder.clicked.connect(self.setSaveFolder)
        self.tbSaveFolder = QtGui.QPlainTextEdit()
        self.tbSaveFolder.setFixedWidth(120)
        self.tbSaveFolder.setFixedHeight(40)
        self.tbSaveFolder.setDisabled(True)

        self.cbClicking = QtGui.QCheckBox("Click Points")

        self.cbKeepEditing = QtGui.QCheckBox("Keep img")
        
        self.cbDrawPoints = QtGui.QCheckBox("Scatter points")
        self.cbDrawPoints.stateChanged.connect(self.plotIdx)

        self.cbDrawNums = QtGui.QCheckBox("show nums")
        self.cbDrawNums.stateChanged.connect(self.plotIdx)

        self.cbHistEqual = QtGui.QCheckBox("Hist Equalize")
        self.cbHistEqual.stateChanged.connect(lambda:self.evCheckBox(self.cbHistEqual))
        
        self.btnGoBackward= QtGui.QPushButton('←')
        self.btnGoBackward.setFixedWidth(60)
        self.btnGoBackward.clicked.connect(self.goBackward)

        self.btnGoForward = QtGui.QPushButton('→')
        self.btnGoForward.setFixedWidth(60)
        self.btnGoForward.clicked.connect(self.goForward)

        self.lbNumFile = QtGui.QLabel("0")
        self.lbNumFile.setFixedWidth(100)

        self.listFile = QtGui.QListWidget()
        self.listFile.setFixedWidth(120)
        

        self.lbNum = QtGui.QLabel("Point Number :")
        self.lbNum.setFixedWidth(100)
        self.tbNum = QtGui.QLineEdit("")
        self.tbNum.setFixedWidth(100)

        self.btnDelete = QtGui.QPushButton('Delete')
        self.btnDelete.setFixedWidth(100)
        self.btnDelete.clicked.connect(self.delete)

        self.btnStripe = QtGui.QPushButton('Draw Stripe')
        self.btnStripe.setFixedWidth(100)
        self.btnStripe.clicked.connect(self.setStripe)
        self.bDrawStripe = False

        self.btnClear = QtGui.QPushButton('Clear')
        self.btnClear.setFixedWidth(100)
        self.btnClear.clicked.connect(self.plotFirstInList)

        self.edt = QtGui.QPlainTextEdit()
        self.edt.setDisabled(True)
        self.edt.setMaximumBlockCount(10)
        self.edt.setFixedWidth(120)

        self.btnQuit = QtGui.QPushButton('Quit')
        self.btnQuit.setFixedWidth(100)
        self.btnQuit.clicked.connect(self.close)


        layoutControl = QtGui.QGridLayout()
        lsControl = [self.lbSaveFolder, self.btnSaveFolder, self.tbSaveFolder, 
                    self.cbClicking, self.cbKeepEditing, self.cbDrawPoints, self.cbDrawNums,
                    self.cbHistEqual, [self.btnGoBackward, self.btnGoForward],
                    self.lbNumFile, self.listFile, self.lbNum, self.tbNum, self.btnDelete, 
                    self.btnStripe, self.btnClear, self.edt, self.btnQuit]
        
        gridW = 1
        for i in range(len(lsControl)):
            if isinstance(lsControl[i], list):
                gridW = max(gridW, len(lsControl[i]))        
        for i in range(len(lsControl)):
            if isinstance(lsControl[i], list):
                for j in range(len(lsControl[i])):
                    layoutControl.addWidget(lsControl[i][j],i,j,1,1)
            else:
                layoutControl.addWidget(lsControl[i],i,0,1,gridW)

        layout = QtGui.QGridLayout()
        layout.addWidget(self.toolbar,0,0,1,4)
        layout.addWidget(self.canvas,1,1,4,3)
        layout.addLayout(layoutControl,1,0,1,1)
        
        self.setLayout(layout)
        self.ax = self.figure.add_subplot(111)
        self.figure.tight_layout()

        self.cbClicking.setChecked(True)
        self.cbKeepEditing.setChecked(True)
        self.cbDrawNums.setChecked(True)
        self.cbDrawPoints.setChecked(True)
        self.cbHistEqual.setChecked(True)