Пример #1
0
 def loadPositiveInteger(self, font, src, dst):
     value = getattr(font.info, src)
     if value is not None:
         value = str(value)
     else:
         value = ""
     setattr(self, dst + "Edit", QLineEdit(value, self))
     validator = QIntValidator(self)
     validator.setBottom(0)
     getattr(self, dst + "Edit").setValidator(validator)
Пример #2
0
    def __init__(self, data, parent=None):
        super(QtWidgets.QWidget, self).__init__(parent)
        self.setupUi(self)
        self.contacts = data

        self.labelNumFrames.setText(str(len(self.contacts[0].scoreArray)))
        self.labelTotalContacts.setText(str(len(self.contacts)))
        self.labelMeanScore.setText(str(mean_score_of_contactArray(self.contacts)))
        self.labelMedianScore.setText(str(median_score_of_contactArray(self.contacts)))
        self.savePlotButton.clicked.connect(self.savePlot)
        self.plotButton.clicked.connect(self.plotAttribute)

        posIntValidator = QIntValidator()
        posIntValidator.setBottom(3)
        self.smoothStrideField.setValidator(posIntValidator)

        self.contactPlotter = ContactPlotter(None, width=4, height=2, dpi=70)
        self.contactPlotter.plot_all_contacts_figure(self.contacts, 0)
        self.plotGridLayout.addWidget(self.contactPlotter)
Пример #3
0
    def __init__(self, *args: Any, **kwargs: Any):

        super().__init__(*args, **kwargs)

        if not self.backend:
            self.backend = FTPBackend()

        layout: QHBoxLayout = QHBoxLayout(self)

        host_label: QLabel = QLabel("Host:", self)
        layout.addWidget(host_label)

        self.host_input = QLineEdit(cast(FTPBackend, self.backend).getHost(), self)
        self.host_input.textChanged.connect(self.parent.updated.emit)
        host_label.setBuddy(self.host_input)
        layout.addWidget(self.host_input)

        username_label: QLabel = QLabel("Username:"******"Password:"******"Port:", self)
        layout.addWidget(port_label)

        self.port_input = QLineEdit(str(cast(FTPBackend, self.backend).getPort()), self)
        self.port_input.setText(str(21))
        validator = QIntValidator(self)
        validator.setBottom(1)
        self.port_input.setValidator(validator)
        port_label.setBuddy(self.port_input)
        layout.addWidget(self.port_input)

        path_label: QLabel = QLabel("Path:", self)
        layout.addWidget(path_label)

        self.path_input = QLineEdit(self.backend.getPath(), self)
        self.path_input.setText("/")
        self.path_input.textChanged.connect(self.parent.updated.emit)
        path_label.setBuddy(self.path_input)
        layout.addWidget(self.path_input)

        self.ftps_checkbox = QCheckBox("FTPS", self)
        self.ftps_checkbox.setChecked(cast(FTPBackend, self.backend).getFTPS())
        layout.addWidget(self.ftps_checkbox)

        self.setLayout(layout)
Пример #4
0
    def __init__(self, font, parent=None):
        super(GeneralTab, self).__init__(parent)
        mainLayout = QGridLayout(self)

        familyNameLabel = QLabel("Family name:", self)
        self.familyNameEdit = QLineEdit(font.info.familyName, self)
        styleNameLabel = QLabel("Style name:", self)
        self.styleNameEdit = QLineEdit(font.info.styleName, self)

        mainLayout.addWidget(familyNameLabel, 0, 0)
        mainLayout.addWidget(self.familyNameEdit, 0, 1, 1, 3)
        mainLayout.addWidget(styleNameLabel, 0, 4)
        mainLayout.addWidget(self.styleNameEdit, 0, 5)

        designerLabel = QLabel("Designer:", self)
        self.designerEdit = QLineEdit(font.info.openTypeNameDesigner, self)

        mainLayout.addWidget(designerLabel, 1, 0)
        mainLayout.addWidget(self.designerEdit, 1, 1, 1, 5)

        designerURLLabel = QLabel("Designer URL:", self)
        self.designerURLEdit = QLineEdit(
            font.info.openTypeNameDesignerURL, self)

        mainLayout.addWidget(designerURLLabel, 2, 0)
        mainLayout.addWidget(self.designerURLEdit, 2, 1, 1, 5)

        manufacturerLabel = QLabel("Manufacturer:", self)
        self.manufacturerEdit = QLineEdit(
            font.info.openTypeNameManufacturer, self)

        mainLayout.addWidget(manufacturerLabel, 3, 0)
        mainLayout.addWidget(self.manufacturerEdit, 3, 1, 1, 5)

        manufacturerURLLabel = QLabel("Manufacturer URL:", self)
        self.manufacturerURLEdit = QLineEdit(
            font.info.openTypeNameManufacturerURL, self)

        mainLayout.addWidget(manufacturerURLLabel, 4, 0)
        mainLayout.addWidget(self.manufacturerURLEdit, 4, 1, 1, 5)

        copyrightLabel = QLabel("Copyright:", self)
        self.copyrightEdit = QLineEdit(font.info.copyright, self)

        mainLayout.addWidget(copyrightLabel, 5, 0)
        mainLayout.addWidget(self.copyrightEdit, 5, 1, 1, 5)

        # TODO: give visual feedback of input data validity using QLineEdit
        # lose focus event
        # http://snorf.net/blog/2014/08/09/using-qvalidator-in-pyqt4-to-validate-user-input/ # noqa
        versionLabel = QLabel("Version:", self)
        if font.info.versionMajor is not None:
            versionMajor = str(font.info.versionMajor)
        else:
            versionMajor = ''
        self.versionMajorEdit = QLineEdit(versionMajor, self)
        self.versionMajorEdit.setAlignment(Qt.AlignRight)
        self.versionMajorEdit.setValidator(QIntValidator(self))
        versionDotLabel = QLabel(".", self)
        if font.info.versionMinor is not None:
            versionMinor = str(font.info.versionMinor)
        else:
            versionMinor = ''
        self.versionMinorEdit = QLineEdit(versionMinor, self)
        validator = QIntValidator(self)
        validator.setBottom(0)
        self.versionMinorEdit.setValidator(validator)

        mainLayout.addWidget(versionLabel, 6, 0)
        mainLayout.addWidget(self.versionMajorEdit, 6, 1)
        mainLayout.addWidget(versionDotLabel, 6, 2)
        mainLayout.addWidget(self.versionMinorEdit, 6, 3)

        dateCreatedLabel = QLabel("Date created:", self)
        dateTime = QDateTime()
        # dateTime.fromString(font.info.openTypeHeadCreated, "yyyy/MM/dd
        # hh:mm:ss") # XXX: why does this not work?
        dateCreated = font.info.openTypeHeadCreated
        if dateCreated:
            parse = dateCreated.split(" ")
            if len(parse) == 2:
                date = parse[0].split("/")
                date = QDate(*(int(val) for val in date))
                dateTime.setDate(date)
                time = parse[1].split(":")
                time = QTime(*(int(val) for val in time))
                dateTime.setTime(time)
        else:
            cur = QDateTime.currentDateTime()
            dateTime.setDate(cur.date())
            dateTime.setTime(cur.time())
        self.dateCreatedEdit = QDateTimeEdit(dateTime, self)

        mainLayout.addWidget(dateCreatedLabel, 6, 4)
        mainLayout.addWidget(self.dateCreatedEdit, 6, 5)

        licenseLabel = QLabel("License:", self)
        self.licenseEdit = QLineEdit(font.info.openTypeNameLicense, self)

        mainLayout.addWidget(licenseLabel, 7, 0)
        mainLayout.addWidget(self.licenseEdit, 7, 1, 1, 5)

        licenseURLLabel = QLabel("License URL:", self)
        self.licenseURLEdit = QLineEdit(font.info.openTypeNameLicenseURL, self)

        mainLayout.addWidget(licenseURLLabel, 8, 0)
        mainLayout.addWidget(self.licenseURLEdit, 8, 1, 1, 5)

        trademarkLabel = QLabel("Trademark:", self)
        self.trademarkEdit = QLineEdit(font.info.trademark, self)

        mainLayout.addWidget(trademarkLabel, 9, 0)
        mainLayout.addWidget(self.trademarkEdit, 9, 1, 1, 5)

        self.setLayout(mainLayout)
Пример #5
0
    def __init__(self, font, parent=None):
        super(MetricsTab, self).__init__(parent)
        mainLayout = QGridLayout()

        styleMapFamilyLabel = QLabel("Style map family name:", self)
        self.styleMapFamilyEdit = QLineEdit(font.info.styleMapFamilyName, self)

        styleMapStyleLabel = QLabel("Style map style name:", self)
        self.styleMapStyleDrop = QComboBox(self)
        items = ["None", "Regular", "Italic", "Bold", "Bold Italic"]
        self.styleMapStyleDrop.insertItems(0, items)
        sn = font.info.styleMapStyleName
        if sn == "regular":
            self.styleMapStyleDrop.setCurrentIndex(1)
        elif sn == "regular italic":
            self.styleMapStyleDrop.setCurrentIndex(2)
        elif sn == "bold":
            self.styleMapStyleDrop.setCurrentIndex(3)
        elif sn == "bold italic":
            self.styleMapStyleDrop.setCurrentIndex(4)
        else:
            self.styleMapStyleDrop.setCurrentIndex(0)

        mainLayout.addWidget(styleMapFamilyLabel, 0, 0)
        mainLayout.addWidget(self.styleMapFamilyEdit, 0, 1, 1, 3)
        mainLayout.addWidget(styleMapStyleLabel, 0, 4)
        mainLayout.addWidget(self.styleMapStyleDrop, 0, 5)

        unitsPerEmLabel = QLabel("Units per em:", self)
        unitsPerEm = str(
            font.info.unitsPerEm) if font.info.unitsPerEm is not None else ''
        self.unitsPerEmEdit = QLineEdit(unitsPerEm, self)
        validator = QIntValidator(self)
        validator.setBottom(0)
        self.unitsPerEmEdit.setValidator(validator)

        ascenderLabel = QLabel("Ascender:", self)
        ascender = str(
            font.info.ascender) if font.info.ascender is not None else ''
        self.ascenderEdit = QLineEdit(ascender, self)
        self.ascenderEdit.setValidator(QIntValidator(self))

        capHeightLabel = QLabel("Cap height:", self)
        capHeight = str(
            font.info.capHeight) if font.info.capHeight is not None else ''
        self.capHeightEdit = QLineEdit(capHeight, self)
        self.capHeightEdit.setValidator(QIntValidator(self))

        mainLayout.addWidget(unitsPerEmLabel, 1, 0)
        mainLayout.addWidget(self.unitsPerEmEdit, 1, 1)
        mainLayout.addWidget(ascenderLabel, 1, 2)
        mainLayout.addWidget(self.ascenderEdit, 1, 3)
        mainLayout.addWidget(capHeightLabel, 1, 4)
        mainLayout.addWidget(self.capHeightEdit, 1, 5)

        italicAngleLabel = QLabel("Italic angle:", self)
        italicAngle = str(
            font.info.italicAngle) if font.info.italicAngle is not None else ''
        self.italicAngleEdit = QLineEdit(italicAngle, self)
        self.italicAngleEdit.setValidator(QDoubleValidator(self))

        descenderLabel = QLabel("Descender:", self)
        descender = str(
            font.info.descender) if font.info.descender is not None else ''
        self.descenderEdit = QLineEdit(descender, self)
        self.descenderEdit.setValidator(QIntValidator(self))

        xHeightLabel = QLabel("x-height:", self)
        xHeight = str(
            font.info.xHeight) if font.info.xHeight is not None else ''
        self.xHeightEdit = QLineEdit(xHeight, self)
        self.xHeightEdit.setValidator(QIntValidator(self))

        mainLayout.addWidget(italicAngleLabel, 2, 0)
        mainLayout.addWidget(self.italicAngleEdit, 2, 1)
        mainLayout.addWidget(descenderLabel, 2, 2)
        mainLayout.addWidget(self.descenderEdit, 2, 3)
        mainLayout.addWidget(xHeightLabel, 2, 4)
        mainLayout.addWidget(self.xHeightEdit, 2, 5)

        noteLabel = QLabel("Note:", self)
        self.noteEdit = QPlainTextEdit(font.info.note, self)

        mainLayout.addWidget(noteLabel, 3, 0)
        mainLayout.addWidget(self.noteEdit, 3, 1, 1, 5)

        self.setLayout(mainLayout)
Пример #6
0
# TODO: QWebView is deprecated. We should use QWebEngineView instead.
#       Currently not possible due to a bug in QGIS (https://issues.qgis.org/issues/18155).
from PyQt5.QtWebKitWidgets import QWebView
# from PyQt5.QtWebEngineWidgets import QWebEngineView

from qgis.gui import QgisInterface
from qgis.core import QgsMapLayer

# NOTE: Do not import anything from gis4wrf.core or other gis4wrf.plugin module depending on core here.
#       The helpers module is used in the bootstrapping UI.

from gis4wrf.plugin.constants import PLUGIN_NAME

DIM_VALIDATOR = QIntValidator()
DIM_VALIDATOR.setBottom(0)
RATIO_VALIDATOR = QIntValidator()
RATIO_VALIDATOR.setBottom(1)
THIS_DIR = Path(__file__)


class StringValidator(QValidator):
    def __init__(self, callback):
        super().__init__()
        self.callback = callback

    def validate(self, s, pos):
        if self.callback(s):
            return QValidator.Acceptable, s, pos
        else:
            return QValidator.Intermediate, s, pos
    def __init__(self, vtable_dir: str, spec: Optional[dict] = None) -> None:
        super().__init__()

        self.vtable_dir = vtable_dir
        self.paths = set()  # type: Set[Path]

        geom = QGuiApplication.primaryScreen().geometry()
        w, h = geom.width(), geom.height()
        self.setWindowTitle("Custom Meteorological Dataset")
        self.setMinimumSize(w * 0.25, h * 0.35)

        layout = QVBoxLayout()

        # button to open folder/files dialog
        hbox = QHBoxLayout()
        layout.addLayout(hbox)
        add_folder_btn = QPushButton('Add folder')
        add_files_btn = QPushButton('Add files')
        remove_selected_btn = QPushButton('Remove selected')
        hbox.addWidget(add_folder_btn)
        hbox.addWidget(add_files_btn)
        hbox.addWidget(remove_selected_btn)
        add_folder_btn.clicked.connect(self.on_add_folder_btn_clicked)
        add_files_btn.clicked.connect(self.on_add_files_btn_clicked)
        remove_selected_btn.clicked.connect(
            self.on_remove_selected_btn_clicked)

        # show added files in a list
        self.paths_list = QListWidget()
        self.paths_list.setSelectionMode(QAbstractItemView.ContiguousSelection)
        layout.addWidget(self.paths_list)

        grid = QGridLayout()
        layout.addLayout(grid)

        # date/time start/end
        self.start_date_input = QDateTimeEdit()
        self.start_date_input.setCalendarPopup(True)

        self.end_date_input = QDateTimeEdit()
        self.end_date_input.setCalendarPopup(True)

        add_grid_labeled_widget(grid, 0, 'Start Date/Time',
                                self.start_date_input)
        add_grid_labeled_widget(grid, 1, 'End Date/Time', self.end_date_input)

        # interval in seconds
        interval_validator = QIntValidator()
        interval_validator.setBottom(1)
        self.interval_input = add_grid_lineedit(grid,
                                                2,
                                                'Interval in seconds',
                                                interval_validator,
                                                required=True)

        # vtable file input
        self.vtable_input, vtable_hbox = create_file_input(
            dialog_caption='Select VTable file',
            is_folder=False,
            start_folder=vtable_dir)
        add_grid_labeled_widget(grid, 3, 'VTable', vtable_hbox)

        btn_box = QDialogButtonBox(QDialogButtonBox.Ok
                                   | QDialogButtonBox.Cancel)
        btn_box.accepted.connect(self.on_ok_clicked)
        btn_box.rejected.connect(self.reject)
        layout.addWidget(btn_box)

        self.setLayout(layout)

        if spec:
            self.paths = set(map(Path, spec['paths']))
            self.base_folder = spec['base_folder']
            self.update_file_list()

            start_date, end_date = spec['time_range']
            for date_input, date in [(self.start_date_input, start_date),
                                     (self.end_date_input, end_date)]:
                date_input.setDateTime(
                    QDateTime(QDate(date.year, date.month, date.day),
                              QTime(date.hour, date.minute)))

            self.interval_input.set_value(spec['interval_seconds'])

            self.vtable_input.setText(spec['vtable'])
Пример #8
0
class Simulator(QWidget):
    def __init__(self, *args, **kwargs):
        super(Simulator, self).__init__(*args, **kwargs)
        self.__simulation = SimulationData()

        self.__manage_window()

        self.__create_layouts()

        self.__create_buttons_and_inputs()

        self.__create_canvas()

        self.__manage_layouts()

        self.__connect_buttons()

        self.__set_timer()

        self.__change_initial_configuration()

        self.show()

    def __manage_window(self):
        self.setWindowTitle("2D Wave Equation Simulator")
        self.setFixedSize(1000, 860)

    def __create_layouts(self):
        self.__main_layout = QtWidgets.QVBoxLayout(self)
        self.__form_layout = QFormLayout(self)
        self.__start_stop_layout = QFormLayout(self)

    def __create_buttons_and_inputs(self):
        self.__start_button = QtWidgets.QPushButton("Start simulation", self)
        self.__stop_button = QtWidgets.QPushButton("Stop simulation", self)
        self.__start_button.setFixedWidth(485)
        self.__stop_button.setFixedWidth(485)
        self.__stop_button.setEnabled(False)

        self.__only_float = QRegExpValidator(QRegExp("-?[0-9]+\.?[0-9]+"))
        self.__only_float_time = QRegExpValidator(QRegExp("[0-9]+\.?[0-9]+"))
        self.__only_int = QIntValidator()
        self.__only_int.setBottom(0)
        self.__only_int.setTop(99)

        self.__label1 = QLabel("Number of points (X-axis):")
        self.__line1 = QLineEdit()
        self.__line1.setValidator(self.__only_int)
        self.__line1.setText("25")

        self.__label2 = QLabel("Number of points (Y-axis):")
        self.__line2 = QLineEdit()
        self.__line2.setValidator(self.__only_int)
        self.__line2.setText("25")

        self.__label3 = QLabel("Maximum simulation time [s]:")
        self.__line3 = QLineEdit()
        self.__line3.setValidator(self.__only_float_time)
        self.__line3.setText("1.0")

        self.__label4 = QPushButton("Alpha:")
        self.__label4.setFixedWidth(135)
        self.__line4 = QLineEdit()
        self.__line4.setValidator(self.__only_float)
        self.__line4.setText("0.0")

        self.__label5 = QPushButton("Beta:")
        self.__label5.setFixedWidth(135)
        self.__line5 = QLineEdit()
        self.__line5.setValidator(self.__only_float)
        self.__line5.setText("0.25")

        self.__label6 = QPushButton("Gamma:")
        self.__label6.setFixedWidth(135)
        self.__line6 = QLineEdit()
        self.__line6.setValidator(self.__only_float)
        self.__line6.setText("0.5")

        self.__label7 = QLabel("Fixed boundary conditions:")
        self.__line7 = QComboBox()
        self.__line7.addItems(["True", "False"])

        self.__label8 = QLabel("Zero-displacement initial condition:")
        self.__line8 = QComboBox()
        self.__line8.addItems(["False", "True"])

        self.__label9 = QLabel("Forcing term:")
        self.__line9 = QComboBox()
        self.__line9.addItems(["False", "True"])

    def __create_canvas(self):
        self.__canvas = Canvas(self)
        self.__canvas.setFixedSize(980, 566)

    def __manage_layouts(self):
        self.__form_layout.addRow(self.__label1, self.__line1)
        self.__form_layout.addRow(self.__label2, self.__line2)
        self.__form_layout.addRow(self.__label3, self.__line3)
        self.__form_layout.addRow(self.__label4, self.__line4)
        self.__form_layout.addRow(self.__label5, self.__line5)
        self.__form_layout.addRow(self.__label6, self.__line6)
        self.__form_layout.addRow(self.__label7, self.__line7)
        self.__form_layout.addRow(self.__label8, self.__line8)
        self.__form_layout.addRow(self.__label9, self.__line9)

        self.__start_stop_layout.addRow(self.__start_button,
                                        self.__stop_button)

        self.__main_layout.addWidget(self.__canvas)
        self.__main_layout.addLayout(self.__form_layout)
        self.__main_layout.addLayout(self.__start_stop_layout)

    def __connect_buttons(self):
        self.__start_button.clicked.connect(lambda: self.__start_simulation())
        self.__stop_button.clicked.connect(lambda: self.__stop_simulation())
        self.__label4.clicked.connect(lambda: self.__show_alpha_description())
        self.__label5.clicked.connect(lambda: self.__show_beta_description())
        self.__label6.clicked.connect(lambda: self.__show_gamma_description())
        self.__line1.textChanged.connect(
            lambda: self.__change_initial_configuration())
        self.__line2.textChanged.connect(
            lambda: self.__change_initial_configuration())
        self.__line3.textChanged.connect(
            lambda: self.__change_initial_configuration())
        self.__line4.textChanged.connect(
            lambda: self.__change_initial_configuration())
        self.__line5.textChanged.connect(
            lambda: self.__change_initial_configuration())
        self.__line6.textChanged.connect(
            lambda: self.__change_initial_configuration())
        self.__line7.currentTextChanged.connect(
            lambda: self.__change_initial_configuration())
        self.__line8.currentTextChanged.connect(
            lambda: self.__change_initial_configuration())
        self.__line9.currentTextChanged.connect(
            lambda: self.__change_initial_configuration())

    def __show_alpha_description(self):
        title = "Description of Alpha parameter"
        description = "Alpha is the factor responsible for damping the membrane movement"
        self.__show_message(QMessageBox.Information, title, description)

    def __show_beta_description(self):
        title = "Description of Beta parameter"
        description = "Beta is the scalar parameter of the Newmark algorithm"
        self.__show_message(QMessageBox.Information, title, description)

    def __show_gamma_description(self):
        title = "Description of Gamma parameter"
        description = "Gamma is the scalar parameter of the Newmark algorithm"
        self.__show_message(QMessageBox.Information, title, description)

    def __show_message(self, message_type, title, description):
        self.__msg = QMessageBox()
        self.__msg.setIcon(message_type)
        self.__msg.setWindowTitle(title)
        self.__msg.setText(description)
        self.__msg.exec_()

    def __disable_gui(self):
        self.__stop_button.setEnabled(True)
        self.__start_button.setEnabled(False)
        self.__line1.setEnabled(False)
        self.__line2.setEnabled(False)
        self.__line3.setEnabled(False)
        self.__line4.setEnabled(False)
        self.__line5.setEnabled(False)
        self.__line6.setEnabled(False)
        self.__line7.setEnabled(False)
        self.__line8.setEnabled(False)
        self.__line9.setEnabled(False)
        self.__label4.setEnabled(False)
        self.__label5.setEnabled(False)
        self.__label6.setEnabled(False)

    def __enable_gui(self):
        self.__stop_button.setEnabled(False)
        self.__start_button.setEnabled(True)
        self.__line1.setEnabled(True)
        self.__line2.setEnabled(True)
        self.__line3.setEnabled(True)
        self.__line4.setEnabled(True)
        self.__line5.setEnabled(True)
        self.__line6.setEnabled(True)
        self.__line7.setEnabled(True)
        self.__line8.setEnabled(True)
        self.__line9.setEnabled(True)
        self.__label4.setEnabled(True)
        self.__label5.setEnabled(True)
        self.__label6.setEnabled(True)

    def __set_timer(self):
        self.__timer = QtCore.QTimer()
        self.__timer.setInterval(100)
        self.__timer.timeout.connect(self.__continue_simulation)

    def __change_initial_configuration(self):
        try:
            self.__n_x = int(self.__line1.text())
            self.__n_y = int(self.__line2.text())
        except:
            return

        if self.__n_x < 3 or self.__n_y < 3:
            return

        if self.__line8.currentText() == "False":
            self.__zero_diaphragm_displacement = False
        elif self.__line8.currentText() == "True":
            self.__zero_diaphragm_displacement = True

        self.__x_net = np.zeros(self.__n_x * self.__n_y, dtype=np.float64)
        self.__y_net = np.zeros(self.__n_x * self.__n_y, dtype=np.float64)

        for j in range(self.__n_y):
            for i in range(self.__n_x):
                self.__x_net[j * self.__n_x + i] = i * 1.0 / self.__n_x
                self.__y_net[j * self.__n_x + i] = j * 1.0 / self.__n_y

        first_step = self.__simulation.get_first_step(
            self.__n_x, self.__n_y, self.__zero_diaphragm_displacement)

        self.__max_value = first_step.max() + 0.0001
        self.__min_value = -self.__max_value

        self.__canvas.axes.cla()
        self.__canvas.axes.set_xlabel("x [m]")
        self.__canvas.axes.set_ylabel("y [m]")
        self.__canvas.axes.set_zlabel("u [m]")
        if not self.__zero_diaphragm_displacement:
            self.__canvas.axes.set_zlim(self.__min_value, self.__max_value)
        else:
            self.__canvas.axes.set_zlim(-0.075, 0.075)

        self.__canvas.axes.set_title(
            "Diaphragm displacement diagram u(x, y, t) \n t = 0.0 s")
        self.__canvas.axes.scatter(self.__x_net,
                                   self.__y_net,
                                   first_step,
                                   linewidth=0,
                                   antialiased=False)
        self.__canvas.draw()

    def __start_simulation(self):
        self.__n_x = int(self.__line1.text())
        self.__n_y = int(self.__line2.text())

        if self.__n_x < 3 or self.__n_y < 3:
            title = "Warning"
            description = "Number of points for X-axis and Y-axis must be at least 3"
            self.__show_message(QMessageBox.Warning, title, description)
            return

        self.__t = float(self.__line3.text())
        self.__alpha = float(self.__line4.text())
        self.__beta = float(self.__line5.text())
        self.__gamma = float(self.__line6.text())

        if self.__line7.currentText() == "False":
            self.__fixed_boundary_conditions = False
        elif self.__line7.currentText() == "True":
            self.__fixed_boundary_conditions = True

        if self.__line8.currentText() == "False":
            self.__zero_diaphragm_displacement = False
        elif self.__line8.currentText() == "True":
            self.__zero_diaphragm_displacement = True

        if self.__line9.currentText() == "False":
            self.__forcing_term_check = False
        elif self.__line9.currentText() == "True":
            self.__forcing_term_check = True

        self.__delta_t = 0.01
        self.__n_t = int(self.__t / self.__delta_t)
        self.__counter = 1

        self.__simulation.change_initial_configuration(
            self.__n_x, self.__n_y, self.__t, self.__alpha, self.__beta,
            self.__gamma, self.__fixed_boundary_conditions,
            self.__zero_diaphragm_displacement, self.__forcing_term_check)

        self.__disable_gui()

        self.__simulation.start_simulation()

        self.__canvas.axes.cla()
        self.__canvas.axes.set_xlabel("x [m]")
        self.__canvas.axes.set_ylabel("y [m]")
        self.__canvas.axes.set_zlabel("u [m]")
        if not self.__zero_diaphragm_displacement:
            self.__canvas.axes.set_zlim(self.__min_value, self.__max_value)
        else:
            self.__canvas.axes.set_zlim(-0.075, 0.075)

        self.__canvas.axes.set_title(
            "Diaphragm displacement diagram u(x, y, t) \n t = 0.0 s")
        self.__canvas.axes.scatter(self.__x_net,
                                   self.__y_net,
                                   self.__simulation.get_actual_step(),
                                   linewidth=0,
                                   antialiased=False)
        self.__canvas.draw()

        self.__timer.start()

    def __continue_simulation(self):
        self.__canvas.axes.cla()
        self.__canvas.axes.set_xlabel("x [m]")
        self.__canvas.axes.set_ylabel("y [m]")
        self.__canvas.axes.set_zlabel("u [m]")
        if not self.__forcing_term_check:
            self.__canvas.axes.set_zlim(self.__min_value, self.__max_value)
        else:
            if self.__fixed_boundary_conditions or self.__simulation.get_actual_step(
            ).mean() < 0.05:
                self.__canvas.axes.set_zlim(-0.075, 0.075)
        self.__canvas.axes.set_title(
            "Diaphragm displacement diagram u(x, y, t) \n t = " +
            str(round(self.__counter * self.__delta_t, 2)) + " s")
        self.__canvas.axes.scatter(self.__x_net,
                                   self.__y_net,
                                   self.__simulation.get_actual_step(),
                                   linewidth=0,
                                   antialiased=False)
        self.__canvas.draw()
        if self.__counter < self.__n_t:
            self.__counter += 1
            self.__simulation.calculate_next_step(self.__counter)
        else:
            self.__stop_simulation()

    def __stop_simulation(self):
        self.__timer.stop()
        self.__enable_gui()
 def set_expireddays_validator(self):
     intValidator = QIntValidator()
     intValidator.setBottom(0)
     self.lineEdit_expireddays.setValidator(intValidator)
Пример #10
0
 def set_container_validator(self):
     intvalidator = QIntValidator()
     intvalidator.setBottom(1)
     self.lineEdit_amount.setValidator(intvalidator)
Пример #11
0
    def setUp(self):
        self.setWindowTitle("Settings")
        self.setSizeGripEnabled(False)

        self.layout = QGridLayout(self)
        self.layout.setSizeConstraint(QLayout.SetFixedSize)

        # ---------------------------------------------------------------------
        portValidator = QIntValidator(self)
        portValidator.setTop(65536)
        portValidator.setBottom(0)

        self.portStartEdit = QLineEdit(str(self.config['port_start']), self)
        self.portStartEdit.setValidator(portValidator)
        self.portEndEdit = QLineEdit(str(self.config['port_end']), self)
        self.portEndEdit.setValidator(portValidator)

        portsLayout = QHBoxLayout()
        portsLayout.addWidget(self.portStartEdit)
        portsLayout.addWidget(self.portEndEdit)
        self.layout.addWidget(QLabel("Listen port range:", self), 0, 0)
        self.layout.addLayout(portsLayout, 0, 1)
        # ---------------------------------------------------------------------
        speedValidator = QIntValidator(self)
        speedValidator.setBottom(0)

        maxDownloadSpeed = str(round(self.config['max_download_speed'] / 1024))
        maxUploadSpeed = str(round(self.config['max_upload_speed'] / 1024))
        self.maxDownSpeedEdit = QLineEdit(maxDownloadSpeed, self)
        self.maxDownSpeedEdit.setValidator(speedValidator)
        self.maxUpSpeedEdit = QLineEdit(maxUploadSpeed, self)
        self.maxUpSpeedEdit.setValidator(speedValidator)

        self.layout.addWidget(QLabel("Maximum download speed (KB/s):", self),
                              1, 0)
        self.layout.addWidget(self.maxDownSpeedEdit, 1, 1)
        self.layout.addWidget(QLabel("Maximum upload speed (KB/s):", self),
                              2, 0)
        self.layout.addWidget(self.maxUpSpeedEdit, 2, 1)
        # ---------------------------------------------------------------------
        torrentCountValidator = QIntValidator(self)
        torrentCountValidator.setTop(50)
        torrentCountValidator.setBottom(2)

        self.torrentCountEdit = QLineEdit(str(self.config['max_torrents']),
                                          self)
        self.torrentCountEdit.setValidator(torrentCountValidator)

        self.layout.addWidget(QLabel("Maximal torrent count:", self), 3, 0)
        self.layout.addWidget(self.torrentCountEdit, 3, 1)
        # ---------------------------------------------------------------------
        activeTorrentsValidator = QIntValidator(self)
        activeTorrentsValidator.setBottom(0)

        self.maxActiveDownloadsEdit = QLineEdit(
                str(self.config['max_active_downloads']), self)
        self.maxActiveDownloadsEdit.setValidator(activeTorrentsValidator)
        self.maxActiveSeedsEdit = QLineEdit(
                str(self.config['max_active_seeds']), self)
        self.maxActiveSeedsEdit.setValidator(activeTorrentsValidator)

        self.layout.addWidget(QLabel("Maximum active downloads:", self), 4, 0)
        self.layout.addWidget(self.maxActiveDownloadsEdit, 4, 1)
        self.layout.addWidget(QLabel("Maximum active seeds:", self), 5, 0)
        self.layout.addWidget(self.maxActiveSeedsEdit, 5, 1)
        # ---------------------------------------------------------------------
        self.resumeDataCheckbox = QCheckBox(self)
        self.resumeDataCheckbox.setChecked(self.config['resume_data'] == 1)

        self.layout.addWidget(QLabel("Enable resume data:", self), 6, 0)
        self.layout.addWidget(self.resumeDataCheckbox, 6, 1)
        # ---------------------------------------------------------------------
        buttonsRow = QHBoxLayout()

        OKButton = QPushButton("Apply", self)
        OKButton.setFocus()
        OKButton.clicked.connect(self.accept)

        cancelButton = QPushButton("Cancel", self)
        cancelButton.clicked.connect(self.reject)

        buttonsRow.addWidget(OKButton)
        buttonsRow.addWidget(cancelButton)
        self.layout.addLayout(buttonsRow, 7, 1)
Пример #12
0
    def adjust_UI(self):
        """Edit the widgets created by main_window"""
        self.setWindowTitle(self.name+' - Comp-Image Analyser - ')

        int_validator    = QIntValidator()    # integers
        nat_validator    = QIntValidator()    # natural numbers 
        nat_validator.setBottom(1)

        #### edit menubar
        menubar = self.menuBar()
        menubar.clear()
        
        # histogram menu saves/loads/resets histogram and gives binning options
        hist_menu =  menubar.addMenu('Histogram')
        save_hist = QAction('Save histogram', self) # save current hist to csv
        save_hist.triggered.connect(self.save_hist_data)
        hist_menu.addAction(save_hist)
        reset_hist = QAction('Reset histogram', self) # reset hist without loading new data
        reset_hist.triggered.connect(self.load_empty_hist)
        hist_menu.addAction(reset_hist)
        
        # load plots from log files
        varplot_menu = menubar.addMenu('Plotting')
        load_varplot = QAction('Load from log file', self)
        load_varplot.triggered.connect(self.load_from_log)
        varplot_menu.addAction(load_varplot)

        #### edit settings tab: choose from list of image handlers ####
        settings_grid = self.tabs.widget(0).layout()
        # remove the settings which are redundant
        for i in reversed(range(settings_grid.count())):
            if i > 1:
                widget = settings_grid.itemAt(i).widget()
                settings_grid.removeWidget(widget)
                widget.setParent(None)

        self.before_choice = []
        self.before_cond   = []
        self.after_choice  = []
        self.after_cond    = []
        self.nhist_label = QLabel('# Histograms:')
        settings_grid.addWidget(self.nhist_label, 1,0,1,1)
        self.nhist_edit = QLineEdit('1', self)
        self.nhist_edit.setValidator(nat_validator)
        settings_grid.addWidget(self.nhist_edit, 1,1,1,1)
        self.nhist_edit.editingFinished.connect(self.set_combo_boxes)
        self.natoms_label = QLabel('Load N atoms:', self)
        settings_grid.addWidget(self.natoms_label, 2,0,1,1)
        self.natoms_edit = QLineEdit(self)
        self.natoms_edit.setValidator(int_validator)
        settings_grid.addWidget(self.natoms_edit, 2,1,1,1)
        self.set_combo_boxes()
        reset_combos_button = QPushButton('Apply Changes', self)
        reset_combos_button.clicked.connect(self.request_update)
        reset_combos_button.resize(reset_combos_button.sizeHint())
        settings_grid.addWidget(reset_combos_button, 5,1,1,1)
        
        #### edit histogram tab: 
        hist_grid = self.tabs.widget(1).layout()
        menubar = self.menuBar() # menu selects which histogram to display
        self.hist_choice = QComboBox(self)
        hist_grid.addWidget(self.hist_choice, 8,0, 1,2)
        self.hist_type = QComboBox(self)
        hist_grid.addWidget(self.hist_type, 8,2, 1,2)
        replot_hist_button = QPushButton('Update plot', self)
        replot_hist_button.clicked.connect(self.update_plot)
        replot_hist_button.clicked.connect(self.display_fit)
        hist_grid.addWidget(replot_hist_button, 8,4, 1,2)
        
        #### edit stats tab: display all histogram statistics ####
        self.reset_stat_labels()
        
        # take the threshold from the second image handler
        self.thresh_toggle.setChecked(True)
Пример #13
0
 def set_valitor(self, widget, bottom=0, top=0):
     intvalitor = QIntValidator()
     intvalitor.setBottom(bottom)
     if top != 0:
         intvalitor.setTop(top)
     widget.setValidator(intvalitor)
Пример #14
0
    if not ui.T5.isChecked():
        ui.Qt5.setText("0")
        ui.Qt5.setDisabled(True)
    else:
        if ui.Qt5.text() == "0":
            ui.Qt5.setText(str(180))
        ui.Qt5.setDisabled(False)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    ui = loadUi('main.ui')
    validatorDouble = QDoubleValidator()
    validatorInt = QIntValidator()
    validatorDouble.setBottom(0)
    validatorInt.setBottom(0)
    ui.Qt1.setValidator(validatorInt)
    ui.Qt2.setValidator(validatorInt)
    ui.Qt3.setValidator(validatorInt)
    ui.Qt4.setValidator(validatorInt)
    ui.Qt5.setValidator(validatorInt)
    ui.Qtot.setValidator(validatorInt)
    ui.eam.setValidator(validatorDouble)
    ui.Qt1.setText(str(180))
    ui.Qt2.setText(str(180))
    ui.Qt3.setText(str(180))
    ui.Qt4.setText(str(180))
    ui.Qt5.setText(str(180))
    ui.T1.stateChanged.connect(state_changed)
    ui.T2.stateChanged.connect(state_changed)
    ui.T3.stateChanged.connect(state_changed)