Exemplo n.º 1
0
def main():
    """The main entry point for this example."""

    # Register the item class to be shown for the valid path extensions
    studiolibrary.registerItem(ImageItem)

    studiolibrary.main(name="Example1", path="data")
Exemplo n.º 2
0
def main():
    """The main entry point for this example."""

    # Register the item class to the extension and ignore all jpgs that
    # contain the string "thumbnail."
    studiolibrary.registerItem(ImageItem, ".jpg", ignore="thumbnail.")
    studiolibrary.registerItem(ImageItem, ".png")
    studiolibrary.registerItem(ImageItem, ".gif")

    # Show the library with the given name and path
    studiolibrary.main(name="Example", path=dirname + "/data")
Exemplo n.º 3
0
        """
        Trigger when the item changes blend value.

        :type value: int
        """
        self.ui.blendSlider.setValue(value)

    def sliderReleased(self):
        """Triggered when the user releases the slider handle."""
        blend = self.ui.blendSlider.value()
        self.item().loadFromSettings(blend=blend,
                                     refresh=False,
                                     showBlendMessage=True)

    def sliderMoved(self, value):
        """
        Triggered when the user moves the slider handle.

        :type value: float
        """
        self.item().loadFromSettings(blend=value,
                                     batchMode=True,
                                     showBlendMessage=True)

    def accept(self):
        """Triggered when the user clicks the apply button."""
        self.item().loadFromSettings(clearSelection=False)


studiolibrary.registerItem(PoseItem, ".pose")
Exemplo n.º 4
0
                                     refresh=False,
                                     showBlendMessage=True)

    def sliderMoved(self, value):
        """
        Triggered when the user moves the slider handle.

        :type value: float
        """
        self.item().loadFromSettings(blend=value,
                                     batchMode=True,
                                     showBlendMessage=True)

    def accept(self):
        """Triggered when the user clicks the apply button."""
        self.item().loadFromSettings(clearSelection=False)


# Register the pose item to the Studio Library
iconPath = studiolibrarymaya.resource().get("icons", "pose.png")

PoseItem.Extensions = [".pose"]
PoseItem.MenuName = "Pose"
PoseItem.MenuOrder = 4
PoseItem.MenuIconPath = iconPath
PoseItem.TypeIconPath = iconPath
PoseItem.CreateWidgetClass = PoseCreateWidget
PoseItem.PreviewWidgetClass = PosePreviewWidget

studiolibrary.registerItem(PoseItem)
Exemplo n.º 5
0
        imageIcon = studiolibrarymaya.resource().icon(basename)

        self.ui.helpImage.setIcon(imageIcon)
        index = self.ui.option.findText(text)
        if index:
            self.ui.option.setCurrentIndex(index)
        if save:
            self.saveSettings()

    def accept(self):
        """
        :rtype: None
        """
        sourceStart = self.sourceStart()
        sourceEnd = self.sourceEnd()

        self.item().loadFromSettings(sourceStart=sourceStart,
                                     sourceEnd=sourceEnd)


# Register the anim item to the Studio Library
iconPath = studiolibrarymaya.resource().get("icons", "animation.png")

AnimItem.Extensions = [".anim"]
AnimItem.MenuName = "Animation"
AnimItem.MenuIconPath = iconPath
AnimItem.TypeIconPath = iconPath
AnimItem.CreateWidgetClass = AnimCreateWidget

studiolibrary.registerItem(AnimItem)
Exemplo n.º 6
0
            [item for item in items if isinstance(item, FolderLibraryItem)])

        action = QtWidgets.QAction("Display only selected libraries", menu)
        action.triggered.connect(callback)
        menu.addAction(action)

        super(FolderLibraryItem, self).contextMenu(menu, items)

    def _filterLibraries(self, items):
        """callback when filtering with the menu
        
        Arguments:
            items {list of items} -- list of FolderLibraryItems
        """
        self.libraryWindow().setFolderFilterLibraryText(" ".join(
            [item.name()[:-4] for item in items]))

    def isDeleteEnabled(self):
        """Check if we can delete this element
        """
        return True

    def FolderLibraryItem(self):
        """
        returns the containing folder library item
        """
        return self


studiolibrary.registerItem(FolderLibraryItem)
Exemplo n.º 7
0
def registerItems():
    """Register all the items from the config file."""
    for name in studiolibrary.config.get("itemRegistry"):
        cls = resolveModule(name)
        studiolibrary.registerItem(cls)
Exemplo n.º 8
0
        """
        :type namespaces: list[str] | None
        """
        self.selectContent(namespaces=namespaces)

    def save(self, objects, path="", iconPath="", metadata=None, **kwargs):
        """
        Save all the given object data to the given path on disc.

        :type objects: list[str]
        :type path: str
        :type iconPath: str
        :type metadata: None or dict
        """
        if path and not path.endswith(".set"):
            path += ".set"

        # Remove and create a new temp directory
        tempPath = mutils.createTempPath() + "/" + self.transferBasename()

        # Save the selection set to the temp location
        mutils.saveSelectionSet(tempPath, objects, metadata=metadata)

        # Move the selection set to the given path using the base class
        contents = [tempPath, iconPath]
        super(SetsItem, self).save(path, contents=contents, **kwargs)


# Register the selection set item to the Studio Library
studiolibrary.registerItem(SetsItem)
Exemplo n.º 9
0
        :type settings: dict
        """
        super(MirrorPreviewWidget, self).setSettings(settings)

        mirrorOption = int(settings.get("mirrorOption"))
        mirrorAnimation = bool(settings.get("mirrorAnimation"))

        self.ui.mirrorOptionComboBox.setCurrentIndex(mirrorOption)
        self.ui.mirrorAnimationCheckBox.setChecked(mirrorAnimation)

    def accept(self):
        """
        Called by the base class when the user clicks the apply button.

        :rtype: None
        """
        self.item().loadFromSettings()


# Register the mirror table item to the Studio Library
iconPath = studiolibrarymaya.resource().get("icons", "mirrorTable.png")

MirrorItem.Extensions = [".mirror"]
MirrorItem.MenuName = "Mirror Table"
MirrorItem.MenuIconPath = iconPath
MirrorItem.TypeIconPath = iconPath
MirrorItem.CreateWidgetClass = MirrorCreateWidget
MirrorItem.PreviewWidgetClass = MirrorPreviewWidget

studiolibrary.registerItem(MirrorItem)
Exemplo n.º 10
0
        state["mirrorOption"] = int(self.mirrorOption())
        state["mirrorAnimation"] = bool(self.mirrorAnimation())

        return state

    def setState(self, state):
        """
        Set the state of the preview widget.

        :type state: dict
        """
        super(MirrorPreviewWidget, self).setState(state)

        mirrorOption = int(state.get("mirrorOption"))
        mirrorAnimation = bool(state.get("mirrorAnimation"))

        self.ui.mirrorOptionComboBox.setCurrentIndex(mirrorOption)
        self.ui.mirrorAnimationCheckBox.setChecked(mirrorAnimation)

    def accept(self):
        """
        Called by the base class when the user clicks the apply button.

        :rtype: None
        """
        self.item().loadFromSettings()


studiolibrary.registerItem(MirrorItem, ".mirror")
Exemplo n.º 11
0
        )

    def sliderMoved(self, value):
        """
        Triggered when the user moves the slider handle.

        :type value: float
        """
        self.item().loadFromSettings(
            blend=value,
            batchMode=True,
            showBlendMessage=True
        )

    def accept(self):
        """Triggered when the user clicks the apply button."""
        self.item().loadFromSettings(clearSelection=False)


# Register the pose item to the Studio Library
iconPath = studiolibrarymaya.resource().get("icons", "pose.png")

PoseItem.Extensions = [".pose"]
PoseItem.MenuName = "Pose"
PoseItem.MenuOrder = 4
PoseItem.MenuIconPath = iconPath
PoseItem.TypeIconPath = iconPath
PoseItem.PreviewWidgetClass = PoseLoadWidget

studiolibrary.registerItem(PoseItem)
Exemplo n.º 12
0
            [item for item in items if isinstance(item, FolderUserItem)])

        action = QtWidgets.QAction("Display only selected users", menu)
        action.triggered.connect(callback)
        menu.addAction(action)

        super(FolderUserItem, self).contextMenu(menu, items)

    def _filterUsers(self, items):
        """callback when filtering with the menu
        
        Arguments:
            items {list of items} -- list of FolderLibraryItems
        """
        self.libraryWindow().setFolderFilterUserText(" ".join(
            [item.name()[:-5] for item in items]))

    def isDeleteEnabled(self):
        """Check if we can delete this element
        """
        return False

    def FolderUserItem(self):
        """
        returns the containing Folder user item
        """
        return self


studiolibrary.registerItem(FolderUserItem)
Exemplo n.º 13
0
            self.ui.connectCheckBox.setEnabled(True)

        connect = ""
        if self.ui.connectCheckBox.isChecked() and text != "replace all":
            connect = "Connect"

        basename = "{0}{1}".format(imageText, connect)
        imageIcon = studiolibraryitems.resource().icon(basename)

        self.ui.helpImage.setIcon(imageIcon)
        index = self.ui.option.findText(text)
        if index:
            self.ui.option.setCurrentIndex(index)
        if save:
            self.saveSettings()

    def accept(self):
        """
        :rtype: None
        """
        sourceStart = self.sourceStart()
        sourceEnd = self.sourceEnd()

        self.item().loadFromSettings(
            sourceStart=sourceStart,
            sourceEnd=sourceEnd
        )


studiolibrary.registerItem(AnimItem, ".anim")
Exemplo n.º 14
0
        namespaces = self.namespaces()
        self.load(namespaces=namespaces)

    def load(self, namespaces=None):
        """
        :type namespaces: list[str] | None
        """
        self.selectContent(namespaces=namespaces)

    def write(self, path, objects, iconPath="", **options):
        """
        Write all the given object data to the given path on disc.

        :type path: str
        :type objects: list[str]
        :type iconPath: str
        :type options: dict
        """
        super(SetsItem, self).write(path, objects, iconPath, **options)

        # Save the selection set to the given path
        mutils.saveSelectionSet(
            path + "/set.json",
            objects,
            metadata={"description": options.get("comment", "")}
        )


# Register the selection set item to the Studio Library
studiolibrary.registerItem(SetsItem)
Exemplo n.º 15
0
                    "menu": {
                        "name": str(mt.rightCount(objects))
                    }
                },
            ])

        return results

    def write(self, path, objects, iconPath="", **options):
        """
        Write the given objects to the given path on disc.

        :type path: str
        :type objects: list[str]
        :type iconPath: str
        :type options: dict
        """
        super(MirrorItem, self).write(path, objects, iconPath, **options)

        # Save the mirror table to the given location
        mutils.saveMirrorTable(
            path + "/mirrortable.json",
            objects,
            metadata={"description": options.get("comment", "")},
            leftSide=options.get("leftSide"),
            rightSide=options.get("rightSide"),
        )


studiolibrary.registerItem(MirrorItem)
Exemplo n.º 16
0
                                       path=path,
                                       iconPath=iconPath)


class SetsCreateWidget(transferitem.CreateWidget):
    def __init__(self, item=None, parent=None):
        """
        :type parent: QtWidgets.QWidget
        :type item: SelectionSetItem
        """
        item = item or SetsItem()
        transferitem.CreateWidget.__init__(self, item, parent=parent)


class SetsPreviewWidget(transferitem.PreviewWidget):
    def __init__(self, *args, **kwargs):
        """
        :type parent: QtWidgets.QWidget
        :type item: SelectionSetItem
        """
        transferitem.PreviewWidget.__init__(self, *args, **kwargs)

        self.ui.optionsToggleBox.setVisible(False)

    def accept(self):
        """Triggered when the user clicks the apply button."""
        self.item().loadFromSettings()


studiolibrary.registerItem(SetsItem, ".set")