コード例 #1
0
    def refresh(self):
        if not self.shown:
            return

        # Don't refresh while editing.
        if self._ui.frameList.state() == Qt.QAbstractItemView.EditingState:
            return

        self._currently_refreshing = True
        try:
            all_keys = get_all_keys()
            all_names = get_all_names()
            self._ui.frameList.clear()
            self.frames_in_list = []

            # Add keys in chronological order.
            for frame in sorted(all_keys.keys()):
                idx = all_keys[frame]
                name = all_names.get(idx, '')
                item = Qt.QListWidgetItem(name)
                item.frame = frame
                item.setFlags(item.flags() | Qt.Qt.ItemIsEditable)

                self._ui.frameList.addItem(item)

                self.frames_in_list.append(frame)

            self.set_selected_frame_from_current_time()
        finally:
            self._currently_refreshing = False
コード例 #2
0
    def populate_transform_list(self):
        self.currently_refreshing = True
        try:
            # Remember which indexes were selected.
            old_selection = [
                idx.row() for idx in self.ui.transformList.selectedIndexes()
            ]

            if self.current_node is None:
                new_transform_list = []
            else:
                curve = CreateCurve(self.current_node)
                new_transform_list = curve.get_transforms()

            self.ui.transformList.clear()
            self.current_transform_list = new_transform_list

            for transform_attr in new_transform_list:
                # The input connection usually goes to worldMatrix[0].  Only show the attribute if
                # it's connected to something else.
                name = transform_attr.name()
                if transform_attr.attrName(longName=True) == 'worldMatrix':
                    # Work around a PyMEL consistency: node.nodeName() returns just the node name,
                    # but attr.nodeName() returns the disambiguated name.  We just want the node
                    # name.
                    name = transform_attr.node().nodeName()
                else:
                    name = '%s.%s' % (transform_attr.node().nodeName(),
                                      transform_attr.attrName(longName=True))

                item = Qt.QListWidgetItem(name)
                item.transform_attr = transform_attr
                self.ui.transformList.addItem(item)

            # Reselect the old selection.  These might not point at the same things, but it prevents
            # losing the selection whenever we refresh.
            self.select_transform_rows(old_selection)

            # Make sure the "remove from curve" button state is enabled after we change the list.
            self.refresh_after_transform_selection_changed()

        finally:
            self.currently_refreshing = False