Beispiel #1
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        # TODO: figure out way to configure for different comm types (TCP, MAVLINK, etc) 
        self.comm = AQSerial()
        
        # Default main window conditions
        self.ui.buttonDisconnect.setEnabled(False)
        self.ui.buttonConnect.setEnabled(True)
        self.ui.comPort.setEnabled(True)
        self.ui.baudRate.setEnabled(True)
        self.ui.status.setText("Not connected to the AeroQuad")
        self.availablePorts = []
        self.updateComPortSelection()
        self.updateBaudRates()
        self.boardConfiguration = {}
        self.manualConnect = True
        
        # Update comm port combo box to use last used comm port
        defaultComPort = xml.find("./Settings/DefaultComPort").text
        commIndex = self.ui.comPort.findText(defaultComPort)
        if commIndex == -1:
            commIndex = 0
        self.ui.comPort.setCurrentIndex(commIndex)
        
        # Load splash screen
        splash = Ui_splashScreen()
        splash.setupUi(splash)
        self.ui.subPanel.addWidget(splash)
        
        # Dynamically configure board type menu and subPanel menu from XML configuration file
        self.configureSubPanelMenu()
        self.activeSubPanel = None
        self.activeSubPanelName = ""

        # Connect GUI slots and signals
        self.ui.comPort.return_handler = self.connectBoard
        self.ui.buttonConnect.clicked.connect(self.connectBoard)
        self.ui.buttonDisconnect.clicked.connect(self.disconnectBoard)
        self.ui.actionExit.triggered.connect(QtGui.qApp.quit)
        self.ui.comPort.currentIndexChanged.connect(self.updateDetectedPorts)
        self.ui.actionBootUpDelay.triggered.connect(self.updateBootUpDelay)
        self.ui.actionCommTimeout.triggered.connect(self.updateCommTimeOut)
Beispiel #2
0
    def __init__(self, ):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.modelArray = [QStandardItemModel(), QStandardItemModel()]
        self.filterProxyArray = [RecursiveProxyModel(), RecursiveProxyModel()]
        self.treeViewArray = [self.ui.treeView, self.ui.treeView_2]
        self.pathLabelArray = [self.ui.labelPath, self.ui.labelPath_2]

        self.setWindowTitle('QDICOMDiffer ' + version)

        # Read the settings from the settings.ini file
        system_location = os.path.dirname(os.path.abspath(sys.argv[0]))
        QSettings.setPath(QSettings.IniFormat, QSettings.SystemScope,
                          system_location)
        self.settings = QSettings("settings.ini", QSettings.IniFormat)
        if os.path.exists(system_location + "/settings.ini"):
            print("Loading settings from " + system_location + "/settings.ini")

        col = self.settings.value('Appearance/directMatchColour')
        if col is None:
            direct_match_colour = default_direct_match_colour
        else:
            direct_match_colour = QColor(col)

        col = self.settings.value('Appearance/indirectMatchColour')
        if col is None:
            indirect_match_colour = default_indirect_match_colour
        else:
            indirect_match_colour = QColor(col)

        font = self.settings.value('Appearance/new_font')

        for i in range(2):
            self.modelArray[i].setHorizontalHeaderLabels(
                ['Tag', 'Description', 'Value', 'Different', 'Index'])
            self.filterProxyArray[i].setSourceModel(self.modelArray[i])
            self.ui.lineEditTagFilter.textChanged.connect(
                self.filterProxyArray[i].set_tag_filter)
            self.ui.lineEditDescFilter.textChanged.connect(
                self.filterProxyArray[i].set_desc_filter)
            self.ui.lineEditValFilter.textChanged.connect(
                self.filterProxyArray[i].set_value_filter)
            self.treeViewArray[i].setModel(self.filterProxyArray[i])
            self.treeViewArray[i].setEditTriggers(
                QAbstractItemView.NoEditTriggers)
            self.treeViewArray[i].setColumnHidden(3, True)
            self.treeViewArray[i].setColumnHidden(4, True)
            # the i=i here is needed to ensure i is within the local namespace, without it i evaluates to 1 both times
            self.ui.checkBoxShowOnlyDifferent.stateChanged.connect(
                lambda state, i=i: self.filterProxyArray[
                    i].set_show_only_different(bool(state)))
            self.treeViewArray[i].file_dropped.connect(
                lambda filepath, i=i: self.load_file(filepath, i))
            self.treeViewArray[i].indirect_match_colour = indirect_match_colour
            self.treeViewArray[i].direct_match_colour = direct_match_colour
            if font is not None:
                self.treeViewArray[i].setFont(font)

        self.ui.splitter.setSizes([100, 0])

        self.ui.actionOpen.triggered.connect(self.open_files)
        self.ui.actionDiff.triggered.connect(self.do_diff)
        self.ui.actionHTML_diff.triggered.connect(self.open_html_diff_window)
        self.ui.actionAbout.triggered.connect(self.open_about_window)
        self.ui.actionAppearance.triggered.connect(self.open_appearance_window)
        self.raw_diff_window = None
        self.html_diff_window = None
        self.appearance_window = None
        self.ui.actionText_diff.triggered.connect(self.open_text_diff_window)
        self.ui.actionExpand_all.triggered.connect(self.expand_all)
        self.ui.actionCollapse_all.triggered.connect(self.collapse_all)
        self.dc_array = [None] * 2

        self.diff_result = None
        self.html_diff_result = None

        # If we were given command line arguments, try and load them
        arguments = sys.argv[1:]
        for number, line in enumerate(arguments):
            self.load_file(line, number)
            # Only ever handle two files
            if number == 1:
                self.ui.splitter.setSizes([50, 50])
                break

        self.show()
Beispiel #3
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.setWindowTitle('QDICOMMiner ' + __version__)

        # TODO: Find a better way of stopping the selection of list items. This only sortof works
        self.ui.listWidget.setSelectionMode(QAbstractItemView.NoSelection)

        system_location = os.path.dirname(os.path.realpath(__file__))
        plugin_locations = [os.path.join(system_location, 'Plugins')]
        self.plugin_manager = PluginManager()
        self.plugin_manager.setPluginPlaces(plugin_locations)
        self.plugin_manager.collectPlugins()
        self.plugin_list = []
        for plugin in self.plugin_manager.getAllPlugins():
            self.plugin_list.append(plugin.name)

        # Read the settings from the settings.ini file
        system_location = os.path.dirname(os.path.realpath(__file__))
        QSettings.setPath(QSettings.IniFormat, QSettings.SystemScope,
                          system_location)
        self.settings = QSettings("settings.ini", QSettings.IniFormat)
        if os.path.exists(system_location + "/settings.ini"):
            print("Loading settings from " + system_location + "/settings.ini")

        # Set the last used output file and analyse folder locations
        output_file = self.settings.value('main/lastOutputFile')
        if output_file is None:
            output_file = 'data.csv'
        if not os.path.isabs(output_file):
            abs_output_location = os.path.join(system_location, output_file)
            self.ui.labelOutputFile.setText(abs_output_location)
        else:
            self.ui.labelOutputFile.setText(output_file)

        folder_to_analyse = self.settings.value('main/lastAnalyseFolder')
        if folder_to_analyse is None:
            folder_to_analyse = ''
        if not os.path.isabs(folder_to_analyse):
            abs_folder_to_analyse = os.path.join(system_location,
                                                 folder_to_analyse)
            self.ui.labelFolderToAnalysePath.setText(abs_folder_to_analyse)
        else:
            self.ui.labelFolderToAnalysePath.setText(folder_to_analyse)

        self.ui.labelFolderToAnalysePath.clicked.connect(
            lambda: self.open_folder_in_explorer(
                self.ui.labelFolderToAnalysePath.text()))
        self.ui.labelOutputFile.clicked.connect(
            lambda: self.open_folder_in_explorer(self.ui.labelOutputFile.text(
            )))

        # Setup a dictionary of key DICOM description and value the DICOM tag
        names = []
        self.DICOM_dic = {}
        for key in dicom_dict.DicomDictionary:
            names.append(dicom_dict.DicomDictionary[key][2])
            self.DICOM_dic[dicom_dict.DicomDictionary[key][2]] = key

        self.completer = QCompleter()
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.model = QStringListModel()
        self.model.setStringList(names)
        self.completer.setModel(self.model)

        self.ui.pushButtonAddListWidget.clicked.connect(
            self.add_new_list_widget)

        self.ui.pushButtonBrowseFolderToAnalysePath.clicked.connect(
            self.browse_for_input_folder)
        self.ui.pushButtonBrowseOutputFilePath.clicked.connect(
            self.browse_for_output_file)
        self.ui.pushButtonDoAnalysis.clicked.connect(self.do_analysis)

        self.count_num_of_files_thread = CountFilesThread()
        self.count_num_of_files_thread.num_of_files.connect(
            self.update_number_of_files)
        self.count_file_number.connect(self.count_num_of_files_thread.count)
        self.count_file_number.emit(self.ui.labelFolderToAnalysePath.text()
                                    )  # Using a signal to keep thread safety

        self.ui.progressBar.setFormat(' %v/%m (%p%)')
        self.ui.progressBar.hide()

        self.ui.actionSave_Template.triggered.connect(self.save_template)
        self.ui.actionLoad_Template.triggered.connect(self.load_template)
        self.ui.actionAbout.triggered.connect(self.open_about_window)

        self.analyse_and_output_data_thread = AnalyseAndOutputDataThread()

        self.show()
Beispiel #4
0
        self.ui.pushButton.setProperty('enabled', False)
        self.ui.progressBar.setProperty('value', 0)
        cursor = self.ui.textBrowser.textCursor()
        cursor.select(QTextCursor.Document)
        cursor.removeSelectedText()
        self.ui.textBrowser.setTextCursor(cursor)

    @pyqtSlot(dict)
    def callback(self, params: dict):
        self.ui.textBrowser.insertPlainText(params['msg'] + '\n')
        self.ui.textBrowser.moveCursor(QTextCursor.End)
        if 'num' in params.keys():
            self.ui.progressBar.setProperty('value', params['num'] if params['num'] >= 0 else 0)
            self.progress_num = params['num']
            if self.progress_num >= 100 or self.progress_num == -1:
                self.ui.pushButton.setProperty('enabled', True)
                self.thread.exit()


if __name__ == '__main__':
    app = QApplication(sys.argv)

    file = QFile("./BreezeStyleSheets/light.qss")
    file.open(QFile.ReadOnly | QFile.Text)
    stream = QTextStream(file)
    app.setStyleSheet(stream.readAll())

    main = MainWindow(Ui_MainWindow())
    main.show()
    sys.exit(app.exec_())
Beispiel #5
0
import sys
from controller.MyMainWindow import MyMainWindow
from ui.mainWindow import Ui_MainWindow
from PyQt5 import QtWidgets

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    mainWindow = MyMainWindow()
    Ui_MainWindow().setupUi(mainWindow)
    mainWindow.show()
    sys.exit(app.exec_())

Beispiel #6
0
    if mode == 'CLI':  #CLI
        logger.info("Mode selected ({})".format(mode))
        from Console import Console
        console = Console()
        console.run()

    elif mode == 'GUI':  #GUI
        logger.info("Mode selected ({})".format(mode))
        from PyQt5.QtWidgets import QApplication, QMainWindow
        from ui.mainWindow import Ui_MainWindow

        app = QApplication(sys.argv)
        logger.info("QApp initialized...")
        MainWindow = QMainWindow()
        logger.info("QMainWindow Initialized")
        ui = Ui_MainWindow()
        ui.setupUi(MainWindow)
        logger.info("ui setup with MainWindow as parent...")
        MainWindow.show()
        logger.info("MainWindow shown...")
        sys.exit(app.exec_())

    elif mode == 'TEST':  #Debug mode in CLI
        output_stream.setLevel(logging.DEBUG)
        logger.info("Mode selected ({})".format(mode))

        fsm = FSM("fsm_setup.txt")
        result = fsm.evaluate("213")
        logger.info("Result: {}".format(result))
        #from Console import Console
        #console = Console()
    def __init__(self, model):
        ''' initialization of class '''
        super().__init__()

        self.value = str()
        # Current Model we use
        self._model = model

        # Application's UI main window
        self._ui = Ui_MainWindow()

        # Setup main window
        self._ui.setupUi(self)

        #setup numpad
        self.qDialog = QDialog()
        self.numpadWindow = Ui_Numpad()
        self.numpadWindow.setupUi(self.qDialog)
        self.numpadWindow.numberToSet.setAlignment(QtCore.Qt.AlignRight)
        self.numpadWindow.numberToSet.setMaxLength(6)
        self.numpadWindow.numberToSet.setReadOnly(True)
        self.qLineValidator = QtGui.QIntValidator

        self.numpadButtons = [
            self.numpadWindow.button0, self.numpadWindow.button1,
            self.numpadWindow.button2, self.numpadWindow.button3,
            self.numpadWindow.button4, self.numpadWindow.button5,
            self.numpadWindow.button6, self.numpadWindow.button7,
            self.numpadWindow.button8, self.numpadWindow.button9
        ]
        for idx, item in enumerate(self.numpadButtons):
            #print(type(item))
            #print(idx)
            item.setText(str(idx))
            item.clicked.connect(lambda: self._buttonpres())

        self.numpadWindow.buttonBackspace.clicked.connect(self._dellast)
        self.numpadWindow.buttonSub.clicked.connect(self._negateValue)

        # Set UI input objects to default state/value
        self._setUiInputsToDefault()

        # Connect UI elements/objects signals and slots
        self._connectSignalSlots()

        # Add menu bar items
        self._addMenubarItems()

        # Setup Plots
        self._bvddPlot = self._ui.graphicsViewBVDD.plot([], [],
                                                        pen=(0, 0, 255))
        self._ui.graphicsViewBVDD.setLabel('left', 'BVDD', units='V')
        self._ui.graphicsViewBVDD.setLabel('bottom', 'Time', units='s')
        self._ui.graphicsViewBVDD.showGrid(x=True, y=True)
        self._ui.graphicsViewBVDD.setYRange(
            DefinedValues.BVDD_Y_MIN_RANGE.value,
            DefinedValues.BVDD_Y_MAX_RANGE.value, 0, True)

        self._temperaturePlot = self._ui.graphicsViewTemperature.plot([], [],
                                                                      pen=(0,
                                                                           255,
                                                                           0))
        self._ui.graphicsViewTemperature.setLabel('left', 'Tj', units='°C')
        self._ui.graphicsViewTemperature.setLabel('bottom', 'Time', units='s')
        self._ui.graphicsViewTemperature.showGrid(x=True, y=True)
        self._ui.graphicsViewTemperature.setYRange(
            DefinedValues.TJ_Y_MIN_RANGE.value,
            DefinedValues.TJ_Y_MAX_RANGE.value, 0, True)

        self._rotorSpeedPlot = self._ui.graphicsViewRotorSpeed.plot([], [],
                                                                    pen=(255,
                                                                         0, 0))
        self._ui.graphicsViewRotorSpeed.setLabel('left',
                                                 'Rotor Speed',
                                                 units='PPS')
        self._ui.graphicsViewRotorSpeed.setLabel('bottom', 'Time', units='s')
        self._ui.graphicsViewRotorSpeed.showGrid(x=True, y=True)
        self._ui.graphicsViewRotorSpeed.setYRange(
            DefinedValues.RS_Y_MIN_RANGE.value,
            DefinedValues.RS_Y_MAX_RANGE.value, 0, True)

        self.__rawCurrentSpeed = 0
        self.__currentSpeed = 0

        self._picIndex = 0  # first image to be replaced

        self._picTimer = QTimer()
        self._picTimer.timeout.connect(self.updatePic)
        self._picTimer.start(DefinedValues.PIC_SWAP_TIME.value)