Exemplo n.º 1
0
    def __init__(self, name, parent, graphic_tabs, existing_tabnames):
        QtWidgets.QWidget.__init__(self, parent)

        graphics_tab_ui = get_ui('graphics_tab.ui', self)

        self.vtk = False
        self.monitors = False

        self.x = []
        self.iteration = 0
        self.y = []
        self.name = name
        self.curve = {}
        self.graphic_tabs = graphic_tabs

        for plot_name, props in PLOT_ITEMS.items():
            plot_btn = getattr(graphics_tab_ui, props['btn_name'])
            plot_btn.setEnabled(PYQTGRAPH_AVAILABLE
                                and plot_name not in existing_tabnames)
            plot_btn.clicked.connect(lambda _, plot_name=plot_name: self.
                                     create_plot_widget(plot_name))

        # monitor btn
        graphics_tab_ui.pushButton_monitors.setEnabled(PYQTGRAPH_AVAILABLE)
        graphics_tab_ui.pushButton_monitors.clicked.connect(
            lambda: self.create_monitor_plot_widget())

        vtk_btn = graphics_tab_ui.pushButton_vtk
        vtk_btn.clicked.connect(lambda: self.create_vtk_widget(load=False))
        vtk_btn.setEnabled(graphic_tabs.loadvtk
                           and 'MFIX_NO_VTK' not in os.environ
                           and VTK_AVAILABLE)
Exemplo n.º 2
0
def make_help_widget(mfixgui):
    """ Create widget for Help filemenu pane """
    help_widget = mfixgui.ui.file_menu_help_widget = get_ui('help.ui')
    help_widget.mfix_local_label.setText(
        f'<a href="file://{MFIX_DOCUMENTATION}">'
        f'Local MFiX Documentation (v {MFIX_VERSION})</a>')
    help_widget.nodeworks_local_label.setText(
        f'<a href="file://{NODEWORKS_DOC_PATH}">'
        f'Local Nodeworks Documentation (v {NODEWORKS_VERSION})</a>'
        if NODEWORKS_DOC_PATH is not None else '')
    help_widget.mfix_local_label.linkActivated.connect(
        lambda url: QDesktopServices.openUrl(QUrl(url)))
    help_widget.nodeworks_local_label.linkActivated.connect(
        lambda url: QDesktopServices.openUrl(QUrl(url)))

    tut_lw = help_widget.tutorial_listwidget
    tut_lw.setAttribute(Qt.WA_MacShowFocusRect, 0)
    tut_lw.setFrameStyle(tut_lw.NoFrame)

    for thumb, text in TUTORIALS:
        label = QLabel(text)
        label.linkActivated.connect(
            lambda url: QDesktopServices.openUrl(QUrl(url)))
        item = QListWidgetItem()
        item.setIcon(QIcon(thumb))
        item.setFlags(Qt.ItemIsEnabled)
        tut_lw.addItem(item)
        tut_lw.setItemWidget(item, label)

    return help_widget
Exemplo n.º 3
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)

        self.vtk_widget = parent

        ui = self.ui = get_ui('distributed.ui', self)

        self.setWindowTitle('Distribution Wizard')

        ui.pushbutton_close.clicked.connect(self.close)
        ui.pushbutton_apply.clicked.connect(self.apply_)
        ui.combobox_distribution.currentIndexChanged.connect(self.dist_changed)
        ui.pushbutton_close.setFocus(False)
Exemplo n.º 4
0
    def __init__(self, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self.gui = parent.gui

        ui = self.ui = get_ui('screenshot_dialog.ui', self)

        self.setWindowTitle('Save Image')

        ui.lineedit_width.dtype = int
        ui.lineedit_height.dtype = int

        ui.toolbutton_browse.clicked.connect(self.browse)
        ui.combobox_template.currentIndexChanged.connect(self.change_size)
Exemplo n.º 5
0
    def __init__(self, parent):
        QtWidgets.QDialog.__init__(self, parent)

        self.vtk_widget = parent

        ui = self.ui = get_ui('new_project_popup.ui', self)

        self.setWindowTitle('Create a new project')

        ui.toolbutton_browse.clicked.connect(self.browse)
        ui.toolbutton_browse.setIcon(get_icon('folder.svg'))

        ui.lineedit_project_name.setValidator(
            QtGui.QRegExpValidator(QtCore.QRegExp(re_valid_run_name_qt)))
        ui.combobox_location.editTextChanged.connect(self.check_location)
Exemplo n.º 6
0
def make_about_widget(mfixgui, label_policy):
    """ Create widget for About filemenu pane """
    about_widget = mfixgui.ui.file_menu_about_widget = get_ui('about.ui')
    about_widget.about_label.setSizePolicy(label_policy)
    about_widget.copy_btn.clicked.connect(lambda: _copy_version_info(mfixgui))
    about_widget.mailinglist_lbl.linkActivated.connect(lambda url: QDesktopServices.openUrl(QUrl(url)))

    about_widget.version_info_txtbrowser.setText(os.linesep.join(get_version_info()))

    splash = about_widget.label_splash
    pixmap = get_pixmap('splash.png', 600, 338)
    splash.setPixmap(pixmap)
    splash.setAlignment(Qt.AlignCenter)

    return about_widget
Exemplo n.º 7
0
    def __init__(self, solver, parent):
        super(RunPopup, self).__init__(parent)
        self.commandline_option_exe = solver if solver else None
        self.mfix_available = False
        self.mfix_exe_cache = {}
        self.solver_list = {}
        self.template_values = {}
        self.cmdline = []  # List of strings
        self.parent = parent
        self.project = parent.project
        self.settings = parent.settings
        self.project_dir = parent.get_project_dir()
        self.gui_comments = self.project.mfix_gui_comments
        self.flag_processes = {}
        self.title = 'Run Solver'

        # load ui
        ui = self.ui = get_ui('run_popup.ui', self)
        ui.layout.setSizeConstraint(ui.layout.SetFixedSize)

        ui.toolbutton_browse.clicked.connect(self.handle_browse_exe)
        ui.toolbutton_browse.setIcon(get_icon('add.svg'))
        ui.toolbutton_browse.setIconSize(sub_icon_size())

        ui.toolbutton_remove.clicked.connect(self.handle_remove_exe)
        ui.toolbutton_remove.setIcon(get_icon('remove.svg'))
        ui.toolbutton_remove.setIconSize(sub_icon_size())

        ui.toolbutton_view_error.clicked.connect(self.show_solver_error)

        ui.listwidget_solver_list.itemSelectionChanged.connect(
            self.update_dialog_options)
        ui.combobox_restart.addItems(RESTART_TYPES.keys())
        ui.combobox_restart.hide()

        ui.button_run.clicked.connect(self.handle_run)
        ui.button_cancel.clicked.connect(self.handle_abort)
        ui.pushbutton_browse_template.clicked.connect(
            self.handle_browse_template)

        n_cpus = multiprocessing.cpu_count()
        ui.groupbox_smp_options.setTitle("SMP Options (%s available locally)" %
                                         plural(n_cpus, "core"))
        ui.groupbox_queue.toggled.connect(self.toggle_run_btn_text)
        ui.widget_queue_options.hide()

        self.initialize_ui()
        self.init_templates()
Exemplo n.º 8
0
def make_build_popup(gui, cwd):
    """ Dialog box for running build_mfixsolver to build the solver """

    build_popup = get_ui('build_popup.ui')

    # override sizeHint
    build_popup.sizeHint = lambda: _size_hint(build_popup)

    # add output widget
    tb = build_popup.textBrowser_output = QTextBrowser()
    build_popup.verticalLayout_run_dialog.addWidget(tb)
    tb.setVisible(False)

    build_popup.cwd = cwd
    build_popup.build_proc = None
    build_popup.min_height = None
    build_popup.setModal(False)
    build_popup.setWindowTitle('Build Solver')

    # don't show options on windows
    visible = os.name != 'nt'

    build_popup.gui_comments = gui.project.mfix_gui_comments

    if not visible:
        build_popup.compiler_groupbox.setVisible(False)
    else:
        _init_compiler(build_popup, build_popup.comboBox_compiler, visible)
        _init_flags(build_popup, visible)

    _init_crow(build_popup, build_popup.checkBox_crow)
    _init_dmp(build_popup, build_popup.checkBox_dmp, visible)
    _init_parallel(build_popup)
    _init_smp(build_popup, build_popup.checkBox_smp, visible)

    build_popup.pushButton_build.clicked.connect(lambda: _build(build_popup))
    build_popup.pushButton_clean.clicked.connect(lambda: _clean(build_popup))
    build_popup.pushButton_cancel.clicked.connect(lambda: _cancel(build_popup))
    build_popup.pushButton_show_out.clicked.connect(lambda: _toggle_output(build_popup))

    _resize_widgets(build_popup, visible)
    _set_output_visible(build_popup, False)
    _update_build_cmd(build_popup)

    fortran_compilers = ['gfortran', 'ifort', 'mpifort', 'mpiifort', 'mpif90']
    build_popup.comboBox_compiler.addItems([compiler for compiler in fortran_compilers if shutil.which(compiler)])

    return build_popup
Exemplo n.º 9
0
    def __init__(self, parent):
        QtWidgets.QDialog.__init__(self, parent)

        self.vtk_widget = parent

        ui = self.ui = get_ui('reactor.ui', self)

        self.setWindowTitle('Reactor Wizard')

        ui.pushbutton_close.clicked.connect(self.close)
        pixmap = get_pixmap('reactor_sketch.png', 199, 349)
        ui.label_image.setPixmap(pixmap)
        ui.lineedit_db.setFocus()

        ui.pushbutton_apply.clicked.connect(self.apply_)

        for widget in widget_iter(self.ui):
            name = str(widget.objectName()).split('_')
            if 'lineedit' in name:
                widget.dtype = float
Exemplo n.º 10
0
    def __init__(self, app, parent=None):
        super(RegionsPopup, self).__init__(parent)
        self.app = app
        self.parent = parent
        self.ui = get_ui('regions_popup.ui', self)

        # key=species, val=data dict
        self.defined_regions = OrderedDict()

        buttons = self.ui.buttonbox.buttons()
        buttons[0].clicked.connect(self.save.emit)
        buttons[1].clicked.connect(self.cancel.emit)
        #self.ui.table.doubleClicked.connect(self.save.emit) # Too easy to double-click accidentally
        #self.ui.table.doubleClicked.connect(self.accept)
        self.ui.table.itemSelectionChanged.connect(
            self.handle_regions_selection)
        self.ui.combobox.currentIndexChanged.connect(self.handle_type)
        self.rejected.connect(self.cancel.emit)
        self._mousePressEvent = self.ui.table.mousePressEvent
        self.ui.table.mousePressEvent = self.mousePressEvent
Exemplo n.º 11
0
def make_new_widget(mfixgui):
    """ Create widget for New filemenu pane """
    new_widget = get_ui('new.ui')
    new_widget.template_list.itemDoubleClicked.connect(
        mfixgui.handle_file_menu_new_project)
    new_widget.template_list.setAttribute(Qt.WA_MacShowFocusRect, 0)
    new_widget.template_list.setFrameStyle(new_widget.template_list.NoFrame)
    new_widget.search_bar.textChanged.connect(
        lambda: mfixgui.handle_filter_new(None))
    new_widget.list_button.clicked.connect(lambda: _switch_to(mfixgui, False))
    new_widget.tile_button.clicked.connect(lambda: _switch_to(mfixgui, True))

    new_widget.single_chk.toggled.connect(mfixgui.handle_filter_new)
    new_widget.tfm_chk.toggled.connect(mfixgui.handle_filter_new)
    new_widget.dem_chk.toggled.connect(mfixgui.handle_filter_new)
    new_widget.cutcell_chk.toggled.connect(mfixgui.handle_filter_new)
    new_widget.chemistry_chk.toggled.connect(mfixgui.handle_filter_new)
    new_widget.tutorials_chk.toggled.connect(mfixgui.handle_filter_new)
    new_widget.benchmarks_chk.toggled.connect(mfixgui.handle_filter_new)
    new_widget.tests_chk.toggled.connect(mfixgui.handle_filter_new)

    new_widget.single_chk.tag = 'single'
    new_widget.tfm_chk.tag = 'tfm'
    new_widget.dem_chk.tag = 'dem'
    new_widget.cutcell_chk.tag = 'cutcell'
    new_widget.chemistry_chk.tag = 'chemistry'
    new_widget.tutorials_chk.tag = 'tutorials'
    new_widget.benchmarks_chk.tag = 'benchmarks'
    new_widget.tests_chk.tag = 'tests'

    mfixgui.ui.file_menu_new_widget = new_widget
    new_widget.setObjectName('new')

    is_tile_mode = mfixgui.settings.value('open_list_mode', 'icon') == 'icon'
    _switch_to(mfixgui, is_tile_mode)

    return new_widget
Exemplo n.º 12
0
def make_settings_widget(mfixgui):
    """ Create widget for Settings filemenu pane """
    widget = mfixgui.ui.file_menu_settings_widget = get_ui('settings.ui')
    settings = mfixgui.settings

    widget.developer_mode.setChecked(int(settings.value('developer_mode', 0)))
    widget.developer_mode.stateChanged.connect(mfixgui.handle_enable_developer_mode)

    widget.collapse_splitters.setChecked(int(settings.value('collapse_qsplitter', 0)))
    widget.collapse_splitters.stateChanged.connect(mfixgui.collapse_splitters)

    widget.show_resources.setChecked(int(settings.value('show_resources', 0)))
    widget.show_resources.stateChanged.connect(mfixgui.resource_monitor.show)

    widget.animation_speed.setValue(int(settings.value('animation_speed', 400)))
    widget.animation_speed.valueChanged.connect(
        lambda n: settings.setValue('animation_speed', n))

    widget.appstyle_combobox.addItems([s.lower() for s in QStyleFactory.keys()])
    widget.appstyle_combobox.currentIndexChanged.connect(
        lambda: _change_app_style(widget.appstyle_combobox.currentText(), mfixgui))
    widget.appstyle_combobox.setCurrentText(settings.value('app_style'))

    return widget
Exemplo n.º 13
0
def make_info_widget(mfixgui):
    """ Create widget for Info filemenu pane """
    widget = mfixgui.ui.file_menu_info_widget = get_ui('info.ui')
    return widget
Exemplo n.º 14
0
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        self.parent = parent
        self.parameter_key_map = {}

        get_ui('regions.ui', self)

        self.extent_lineedits = [
            self.lineedit_regions_from_x, self.lineedit_regions_to_x,
            self.lineedit_regions_from_y, self.lineedit_regions_to_y,
            self.lineedit_regions_from_z, self.lineedit_regions_to_z
        ]
        for ext in self.extent_lineedits:
            ext.allow_parameters = True
            ext.dtype = float
            ext.help_text = 'Physical coordinates describing the bounds of the region.'

        self.lineedit_regions_name.help_text = 'Name of the region. Used througout the gui to reference the region'
        self.combobox_stl_shape.help_text = 'Shape to be used to select facets.'
        self.checkbox_slice_facets.help_text = 'Slice facets if the facet is on the selection boundary.'
        for wid in [
                self.lineedit_filter_x, self.lineedit_filter_y,
                self.lineedit_filter_z
        ]:
            wid.allow_parameters = True
            wid.help_text = 'Vector to filter facets with. If the facet '\
                            'normal is the same as the vector, then the facet'\
                            ' will be added to the region, else discarded.'
        self.lineedit_deviation_angle.allow_parameters = True
        self.lineedit_deviation_angle.help_text = 'Angle to provide a'\
            'tolerence to the filtering of facets based on the facet normal.'

        self.toolbutton_region_add.clicked.connect(self.new_region)
        self.toolbutton_region_delete.clicked.connect(self.delete_region)
        self.toolbutton_region_delete.setEnabled(False)  #Need a selection
        self.toolbutton_region_copy.clicked.connect(self.copy_region)
        self.toolbutton_region_copy.setEnabled(False)  #Need a selection
        self.toolbutton_color.clicked.connect(self.change_color)

        tablewidget = self.tablewidget_regions
        tablewidget.dtype = OrderedDict
        tablewidget._setModel()
        tablewidget.set_selection_model()
        tablewidget.set_value(OrderedDict())
        tablewidget.set_columns(['visible', 'color', 'type', 'used by'])
        tablewidget.show_vertical_header(True)
        tablewidget.auto_update_rows(True)
        tablewidget.new_selection.connect(self.update_region_parameters)
        tablewidget.clicked.connect(self.cell_clicked)
        tablewidget.default_value = OrderedDict()
        self.inhibit_toggle = True

        self.widget_region_parameters.setEnabled(False)
        for widget in widget_iter(self.widget_region_parameters):
            if hasattr(widget, 'value_updated'):
                widget.value_updated.connect(self.region_value_changed)

                # example <name>: lineedit_regions_to_x
                name = str(widget.objectName())

                # set extent limits
                if '_to_' in name or '_from_' in name:
                    kinfo = name.split('_')
                    widget.key = '_'.join(kinfo[-2:])
                    widget.dtype = float
                    widget.setValInfo(max=Equation(kinfo[-1] + 'max'),
                                      min=Equation(kinfo[-1] + 'min'))
                elif 'name' in name:
                    widget.key = 'name'
                    widget.dtype = str
                elif 'stl_shape' in name:
                    widget.key = 'stl_shape'
                    widget.dtype = str
                elif 'slice' in name:
                    widget.key = 'slice'
                    widget.dtype = bool
                elif 'filter' in name:
                    widget.key = '_'.join(name.split('_')[-2:])
                    widget.dtype = float
                elif 'deviation_angle' in name:
                    widget.key = 'deviation_angle'
                    widget.dtype = float
                elif 'equilibrant' in name:
                    widget.key = 'equilibrant'
                    widget.dtype = bool
                elif 'invert' in name:
                    widget.key = 'invert'
                    widget.dtype = bool
        self.error = self.parent.error
        self.warning = self.warn = self.parent.warn

        self.checkbox_selectfacets.clicked.connect(self.stl_type_changed)
        self.checkbox_selectfacets.toggled.connect(
            lambda c: self.groupbox_stl.setEnabled(c))
        self.groupbox_filter_facets.clicked.connect(self.filter_facets_changed)

        # default region buttons
        for btn, region in [(self.toolbutton_region_a, 'all'),
                            (self.toolbutton_region_l, 'left'),
                            (self.toolbutton_region_r, 'right'),
                            (self.toolbutton_region_t, 'top'),
                            (self.toolbutton_region_b, 'bottom'),
                            (self.toolbutton_region_f, 'front'),
                            (self.toolbutton_region_back, 'back')]:
            btn.clicked.connect(
                lambda ignore, r=region: self.new_default_region(r))
            btn.setIcon(get_icon(region + '_region.svg'))
            btn.setToolTip(region)
            btn.setIconSize(sub_icon_size())
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.ui = get_ui('output_selection_popup.ui', self)

        self.setWindowTitle('Delete Files?')
Exemplo n.º 16
0
    def __init__(self, app, parent=None, phases='GLCS'):
        super(SpeciesPopup, self).__init__(parent)
        self.app = app
        self.phases = phases
        self.include_comments = False
        self.default_phase = phases[0] if phases else ''
        self.density_enabled = True
        datadir = os.path.abspath(os.path.dirname(__file__))
        self.load_burcat(os.path.join(datadir, 'burcat.pickle'))
        ui = self.ui = get_ui('species_popup.ui', self)

        # key=species, val=data tuple.  can add phase to key if needed
        self.defined_species = OrderedDict()
        self.extra_aliases = set()  # To support enforcing uniqueness
        self.mfix_keywords = set(k.lower()
                                 for k in self.parent().keyword_doc.keys())
        self.mfix_fortran_globals = set()  # TODO: implement this
        # uniqueness of aliases across all phases

        self.search_results = []
        self.user_species_names = set()

        # Set up UI
        ui.lineedit_search.textChanged.connect(self.do_search)
        ui.pushbutton_import.clicked.connect(self.do_import)
        ui.pushbutton_import.setEnabled(False)
        ui.tablewidget_search.itemSelectionChanged.connect(
            self.handle_search_selection)
        ui.tablewidget_defined_species.itemSelectionChanged.connect(
            self.handle_defined_species_selection)

        ui.pushbutton_new.clicked.connect(self.handle_new)
        ui.pushbutton_copy.clicked.connect(self.handle_copy)
        ui.checkbox_include_comments.clicked.connect(
            self.handle_include_comments)

        for phase in 'GLSC':
            button = getattr(self.ui, 'pushbutton_%s' % phase)
            button.clicked.connect(self.handle_phase)

        cb = ui.combobox_phase
        cb.currentIndexChanged.connect(self.handle_combobox_phase)
        for i, t in enumerate(phase_names):
            get_combobox_item(cb, i).setToolTip(t)

        #http://stackoverflow.com/questions/15845487/how-do-i-prevent-the-enter-key-from-closing-my-qdialog-qt-4-8-1
        # Do not use buttonbox.  https://mfix.netl.doe.gov/gitlab/develop/mfix/issues/101
        buttons = (ui.pushbutton_ok, ui.pushbutton_cancel)
        buttons[0].clicked.connect(lambda: (self.save.emit(), self.close()))
        buttons[1].clicked.connect(lambda: (self.cancel.emit(), self.close()))

        class AliasValidator(QValidator):

            # Make sure aliases are unique
            def __init__(self, parent=None):
                super(AliasValidator, self).__init__()
                self.parent = parent

            def validate(self, text, pos):
                if text == "":
                    self.parent.set_ok_button(False)
                    return (QValidator.Intermediate, text, pos)
                dig_start = text[0].isdigit()
                und_start = text[0] == '_'
                not_alphanum_und = not all(c.isalnum() or c == '_'
                                           for c in text)
                if dig_start or und_start or not_alphanum_und:
                    return (QValidator.Invalid, text, pos)
                current_species = self.parent.current_species
                if current_species not in self.parent.defined_species:  # Why would this happen?
                    self.parent.set_ok_button(False)
                    return (QValidator.Invalid, text, pos)
                current_alias = self.parent.defined_species[
                    current_species].get('alias')
                if current_alias is None:
                    self.parent.set_ok_button(False)
                    return (QValidator.Invalid, text, pos)
                for v in self.parent.defined_species.values():
                    v_alias = v.get('alias', '')
                    if v_alias.lower() == current_alias.lower(
                    ):  # Skip selected item
                        continue
                    if v_alias.lower() == text.lower():
                        self.parent.set_ok_button(False,
                                                  'Alias must be unique')
                        return (QValidator.Intermediate, text, pos)
                tlower = text.lower()
                if tlower in self.parent.extra_aliases:
                    self.parent.set_ok_button(False, 'Alias must be unique')
                    return (QValidator.Intermediate, text, pos)
                if tlower in self.parent.mfix_keywords:
                    self.parent.set_ok_button(False,
                                              '%s is an MFiX keyword' % text)
                    return (QValidator.Intermediate, text, pos)
                self.parent.set_ok_button(True)
                return (QValidator.Acceptable, text, pos)

        lineedit = ui.lineedit_alias
        lineedit.setValidator(AliasValidator(parent=self))
        lineedit.editingFinished.connect(self.handle_alias)

        for line_edit in (ui.lineedit_mol_weight, ui.lineedit_h_f,
                          ui.lineedit_density):
            line_edit.setValidator(QDoubleValidator())

        self.species_panel_items = [
            ui.label_species, ui.lineedit_alias, ui.lineedit_mol_weight,
            ui.lineedit_h_f, ui.lineedit_density, ui.tablewidget_params
        ]

        hv = QHeaderView
        for tw in (self.tablewidget_search, self.tablewidget_defined_species):
            resize_column(tw, 0, hv.Stretch)
            resize_column(tw, 1, hv.ResizeToContents)
        tw = self.tablewidget_params
        for i in (0, 1):
            resize_column(tw, i, hv.Stretch)

        self.set_ok_button(False)  # nothing to accept
        self.clear_species_panel()