Esempio n. 1
0
    def populate(self):
        """ Populate the table with the data """

        self.clear()

        numAttr = self.data.numAttributes()
        numParticles = self.data.numParticles()

        self.attrs = getAttrs(self.data.numAttributes, self.data.attributeInfo,
                              True)
        self.setColumnCount(numAttr)
        self.setRowCount(numParticles)
        self.horizontalHeader().setSectionResizeMode(QHeaderView.Interactive)
        for col, (_, attr) in enumerate(self.attrs):
            item = QTableWidgetItem(attr.name)
            tooltip = '<p><tt>&nbsp;Name: {}<br>&nbsp;Type: {}<br>Count: {}</tt></p>'.\
                      format(attr.name, partio.TypeName(attr.type), attr.count)
            item.setToolTip(tooltip)
            self.setHorizontalHeaderItem(col, item)
        self.horizontalHeader().setStretchLastSection(False)
        self.setVerticalHeaderLabels(
            [str(pnum) for pnum in range(numParticles)])
        self.setTabKeyNavigation(True)
        self.horizontalHeader().setSectionsMovable(False)

        # Populate it with the particle data
        self.widgets = []
        for pnum in range(numParticles):
            self.populateParticle(pnum)

        self.horizontalHeader().resizeSections(QHeaderView.ResizeToContents)
        self.verticalHeader().resizeSections(QHeaderView.ResizeToContents)
Esempio n. 2
0
    def populate(self):
        """ Populates the table of fixed attributes """

        self.widgets = []

        # If no widgets, just drop that in
        numAttrs = self.data.numFixedAttributes()
        if not numAttrs:
            self.table.hide()
            self.noAttrLabel.show()
            return

        self.table.show()
        self.noAttrLabel.hide()
        self.table.setColumnCount(1)
        self.table.setRowCount(numAttrs)
        self.attrs = getAttrs(self.data.numFixedAttributes, self.data.fixedAttributeInfo, True)

        for row, (_, attr) in enumerate(self.attrs):
            item = QTableWidgetItem(attr.name)
            tooltip = '<p><tt>&nbsp;Name: {}<br>&nbsp;Type: {}<br>Count: {}</tt></p>'.\
                      format(attr.name, partio.TypeName(attr.type), attr.count)
            item.setToolTip(tooltip)
            self.table.setVerticalHeaderItem(row, item)
            value = self.data.getFixed(attr)
            widget = getWidget(value, self.data, attr)
            self.table.setCellWidget(row, 0, widget)
            self.widgets.append(widget)
        self.table.horizontalHeader().setStretchLastSection(False)
        self.table.setTabKeyNavigation(True)
        self.table.horizontalHeader().setSectionsMovable(False)

        self.table.horizontalHeader().resizeSections(QHeaderView.ResizeToContents)
        self.table.verticalHeader().resizeSections(QHeaderView.ResizeToContents)
Esempio n. 3
0
    def update_options_form(self):
        """Update the widget values in the options form, based on the current
        values in self.options

        """

        filtered_options = copy.deepcopy(self.options)

        filtered_defaults = dict(BoutMesh.user_options_factory.defaults)
        filtered_defaults.update(
            tokamak.TokamakEquilibrium.user_options_factory.defaults)
        filtered_defaults.update(
            tokamak.TokamakEquilibrium.nonorthogonal_options_factory.defaults)

        # evaluate filtered_defaults using the values in self.options, so that any
        # expressions get evaluated
        filtered_default_values = dict(
            BoutMesh.user_options_factory.create(self.options))
        try:
            filtered_default_values.update(
                tokamak.TokamakEquilibrium.user_options_factory.create(
                    self.options))
            if not hasattr(self, "eq"):
                filtered_default_values.update(
                    tokamak.TokamakEquilibrium.nonorthogonal_options_factory.
                    create(self.options))
            else:
                # Use the object if it exists because some defaults are updated when the
                # Equilibrium is created
                filtered_default_values.update(
                    self.eq.nonorthogonal_options_factory.create(self.options))
        except (ValueError, TypeError) as e:
            self._popup_error_message(e)
            return

        # Skip options handled specially elsewhere
        filtered_options.pop("orthogonal", None)
        del filtered_defaults["orthogonal"]

        self.options_form.setSortingEnabled(False)
        self.options_form.cellChanged.disconnect(self.options_form_changed)
        self.options_form.setRowCount(len(filtered_defaults))

        for row, (key, value) in enumerate(sorted(filtered_defaults.items())):
            item0 = QTableWidgetItem(key)
            item0.setFlags(item0.flags() & ~Qt.ItemIsEditable)
            item0.setToolTip(value.doc)
            self.options_form.setItem(row, 0, item0)
            if key in filtered_options:
                value_to_set = str(filtered_options[key])
            else:
                value_to_set = f"{filtered_default_values[key]} (default)"
            item1 = QTableWidgetItem(value_to_set)
            item1.setToolTip(textwrap.fill(value.doc))
            self.options_form.setItem(row, 1, item1)

        self.options_form.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)
        self.options_form.setSortingEnabled(True)
        self.options_form.cellChanged.connect(self.options_form_changed)
Esempio n. 4
0
    def populate(self):
        """ Populate the table with the data """

        self.clear()

        numAttr = self.data.numAttributes()
        numParticles = self.data.numParticles()

        self.attrs = getAttrs(self.data.numAttributes, self.data.attributeInfo, True)
        self.setColumnCount(numAttr)
        self.setRowCount(numParticles)
        self.horizontalHeader().setSectionResizeMode(QHeaderView.Interactive)
        for col, (_, attr) in enumerate(self.attrs):
            item = QTableWidgetItem(attr.name)
            tooltip = '<p><tt>&nbsp;Name: {}<br>&nbsp;Type: {}<br>Count: {}</tt></p>'.\
                      format(attr.name, partio.TypeName(attr.type), attr.count)
            item.setToolTip(tooltip)
            self.setHorizontalHeaderItem(col, item)
        self.horizontalHeader().setStretchLastSection(False)
        self.setVerticalHeaderLabels([str(pnum) for pnum in range(numParticles)])
        self.setTabKeyNavigation(True)
        self.horizontalHeader().setSectionsMovable(False)

        # Populate it with the particle data
        self.widgets = []
        for pnum in range(numParticles):
            self.populateParticle(pnum)

        self.horizontalHeader().resizeSections(QHeaderView.ResizeToContents)
        self.verticalHeader().resizeSections(QHeaderView.ResizeToContents)
Esempio n. 5
0
    def populate(self):
        """ Populates the table of fixed attributes """

        self.widgets = []

        # If no widgets, just drop that in
        numAttrs = self.data.numFixedAttributes()
        if not numAttrs:
            self.table.hide()
            self.noAttrLabel.show()
            return

        self.table.show()
        self.noAttrLabel.hide()
        self.table.setColumnCount(1)
        self.table.setRowCount(numAttrs)
        self.attrs = getAttrs(self.data.numFixedAttributes,
                              self.data.fixedAttributeInfo, True)

        for row, (_, attr) in enumerate(self.attrs):
            item = QTableWidgetItem(attr.name)
            tooltip = '<p><tt>&nbsp;Name: {}<br>&nbsp;Type: {}<br>Count: {}</tt></p>'.\
                      format(attr.name, partio.TypeName(attr.type), attr.count)
            item.setToolTip(tooltip)
            self.table.setVerticalHeaderItem(row, item)
            value = self.data.getFixed(attr)
            widget = getWidget(value, self.data, attr)
            self.table.setCellWidget(row, 0, widget)
            self.widgets.append(widget)
        self.table.horizontalHeader().setStretchLastSection(False)
        self.table.setTabKeyNavigation(True)
        self.table.horizontalHeader().setSectionsMovable(False)

        self.table.horizontalHeader().resizeSections(
            QHeaderView.ResizeToContents)
        self.table.verticalHeader().resizeSections(
            QHeaderView.ResizeToContents)