def populateTable(self): pixmap = QtGui.QPixmap(20, 20) pixmap.fill(QtGui.QColor(0, 255, 0)) iconOn = QtGui.QIcon(pixmap) pixmapOff = QtGui.QPixmap(20, 20) pixmapOff.fill(QtGui.QColor(255, 0, 0)) iconOff = QtGui.QIcon(pixmapOff) modules = utils.returnRigModules() self.modTable.setRowCount(100 + len(modules)) counter = 0 for module in modules: aimState = False pinState = False #get module name moduleName = cmds.getAttr(module + ".moduleName") if cmds.objExists(module + ".aimMode"): aimState = cmds.getAttr(module + ".aimMode") if cmds.objExists(module + ".pinned"): pinState = cmds.getAttr(module + ".pinned") moduleItem = QtWidgets.QTableWidgetItem(moduleName) self.modTable.setItem(counter, 0, moduleItem) if aimState: lockItem = QtWidgets.QTableWidgetItem(iconOn, "") else: lockItem = QtWidgets.QTableWidgetItem(iconOff, "") self.modTable.setItem(counter, 2, lockItem) if pinState: pinItem = QtWidgets.QTableWidgetItem(iconOn, "") else: pinItem = QtWidgets.QTableWidgetItem(iconOff, "") self.modTable.setItem(counter, 1, pinItem) counter += 1
def createContextMenu(self, point): self.contextMenu = QtWidgets.QMenu() selectIcon = QtGui.QIcon((utils.returnFriendlyPath( os.path.join(self.iconsPath, "System/select.png")))) self.contextMenu.addAction(selectIcon, "Select All", self.selectAllInList) self.contextMenu.addAction("Clear Selection", self.clearListSelection) self.contextMenu.exec_(self.moduleList.mapToGlobal(point))
def findCharacters(self): allNodes = cmds.ls(type="network") characterNodes = [] for node in allNodes: attrs = cmds.listAttr(node) if "rigModules" in attrs: characterNodes.append(node) # go through each node, find the character name, the namespace on the node, and the picker attribute for node in characterNodes: try: namespace = cmds.getAttr(node + ".namespace") except: namespace = cmds.getAttr(node + ".name") # add the icon found on the node's icon path attribute to the tab iconPath = cmds.getAttr(node + ".iconPath") iconPath = utils.returnNicePath(self.projectPath, iconPath) icon = QtGui.QIcon(iconPath) self.characterCombo.addItem(icon, namespace)
def importSkinWeights_populate(self): """ Populate the interface with an entry for each piece of selected geometry. Each entry will have the geometry name and allow the user to point to the geometry's .weight file. """ # get current selection selection = cmds.ls(sl=True) if len(selection) > 0: # Create headers font = QtGui.QFont() font.setPointSize(12) font.setBold(True) headerLayout = QtWidgets.QHBoxLayout() self.importSkinWeights_VLayout.addLayout(headerLayout) headerExport = QtWidgets.QLabel(" ") headerExport.setStyleSheet("background: transparent;") headerLayout.addWidget(headerExport) headerGeo = QtWidgets.QLabel("Mesh") headerGeo.setStyleSheet("background: transparent;") headerGeo.setMinimumSize(QtCore.QSize(180, 20)) headerGeo.setMaximumSize(QtCore.QSize(180, 20)) headerLayout.addWidget(headerGeo) headerGeo.setFont(font) headerFileName = QtWidgets.QLabel("Weight File") headerFileName.setStyleSheet("background: transparent;") headerLayout.addWidget(headerFileName) headerFileName.setMinimumSize(QtCore.QSize(180, 20)) headerFileName.setMaximumSize(QtCore.QSize(180, 20)) headerFileName.setFont(font) # get a list of weight files weightFiles = [] for root, subFolders, files in os.walk(self.toolsPath): for file in files: if file.rpartition(".")[2] == "weights": fullPath = utils.returnFriendlyPath(os.path.join(root, file)) weightFiles.append(fullPath) print weightFiles # loop through selection, checking selection is valid and has skinCluster for each in selection: try: # get dagPath and shape and create a nice display name dagPath = cmds.ls(each, long=True)[0] shapeNode = cmds.listRelatives(dagPath, children=True) nicename = each.rpartition("|")[2] except Exception, e: traceback.format_exc() try: if cmds.nodeType(dagPath + "|" + shapeNode[0]) == "mesh": # create HBoxLayout layout = QtWidgets.QHBoxLayout() layout.setSpacing(10) self.importSkinWeights_VLayout.addLayout(layout) # create checkbox checkBox = QtWidgets.QCheckBox() layout.addWidget(checkBox) checkBox.setChecked(True) # create non editable line edit geoName = QtWidgets.QLabel(nicename + " : ") geoName.setStyleSheet("background: transparent;") geoName.setProperty("dag", dagPath) layout.addWidget(geoName) geoName.setMinimumSize(QtCore.QSize(100, 30)) geoName.setMaximumSize(QtCore.QSize(100, 30)) # create editable line edit skinFileName = QtWidgets.QLineEdit() layout.addWidget(skinFileName) skinFileName.setMinimumSize(QtCore.QSize(205, 30)) skinFileName.setMaximumSize(QtCore.QSize(205, 30)) # try to find a matching weight file for file in weightFiles: compareString = file.rpartition("/")[2].partition(".")[0] if nicename.lower() == compareString.lower(): skinFileName.setText(file) # check if geometry has weights file associated already if cmds.objExists(dagPath + ".weightFile"): path = cmds.getAttr(dagPath + ".weightFile") path = utils.returnFriendlyPath(path) if os.path.exists(path): skinFileName.setText(path) # browse button browseBtn = QtWidgets.QPushButton() layout.addWidget(browseBtn) browseBtn.setMinimumSize(35, 35) browseBtn.setMaximumSize(35, 35) icon = QtGui.QIcon(os.path.join(self.iconsPath, "System/fileBrowse.png")) browseBtn.setIconSize(QtCore.QSize(30, 30)) browseBtn.setIcon(icon) browseBtn.clicked.connect(partial(self.importSkinWeights_fileBrowse, skinFileName)) except Exception, e: print traceback.format_exc()
def buildExportWeightsUI(self): """ Build the interface for exporting the skin weights. An entry is added for each piece of selected geometry. The user then has the ability to specify a .weight file name for the associated geometry. The user also specifies where they would like the weight files saved to. .. image:: /images/exportWeights.png """ if cmds.window("ART_exportSkinWeightsUI", exists=True): cmds.deleteUI("ART_exportSkinWeightsUI", wnd=True) # launch a UI to get the name information self.exportSkinWeights_Win = QtWidgets.QMainWindow(self.mainUI) # size policies mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) # load stylesheet styleSheetFile = utils.returnNicePath( self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss") f = open(styleSheetFile, "r") self.style = f.read() f.close() # create the main widget self.exportSkinWeights_mainWidget = QtWidgets.QWidget() self.exportSkinWeights_Win.setCentralWidget( self.exportSkinWeights_mainWidget) # set qt object name self.exportSkinWeights_Win.setObjectName("ART_exportSkinWeightsUI") self.exportSkinWeights_Win.setWindowTitle("Export Skin Weights") # create the mainLayout for the ui self.exportSkinWeights_mainLayout = QtWidgets.QVBoxLayout( self.exportSkinWeights_mainWidget) self.exportSkinWeights_mainLayout.setContentsMargins(5, 5, 5, 5) self.exportSkinWeights_Win.resize(450, 600) self.exportSkinWeights_Win.setSizePolicy(mainSizePolicy) self.exportSkinWeights_Win.setMinimumSize(QtCore.QSize(450, 600)) self.exportSkinWeights_Win.setMaximumSize(QtCore.QSize(450, 600)) # create the background image self.exportSkinWeights_frame = QtWidgets.QFrame() self.exportSkinWeights_mainLayout.addWidget( self.exportSkinWeights_frame) self.exportSkinWeights_frame.setObjectName("dark") # create widgetLayout self.exportSkinWeights_widgetLayout = QtWidgets.QVBoxLayout( self.exportSkinWeights_frame) # create the hboxLayout for lineEdit and browser button self.exportSkinWeights_browseLayout = QtWidgets.QHBoxLayout() self.exportSkinWeights_widgetLayout.addLayout( self.exportSkinWeights_browseLayout) # create the line edit for the export path self.exportSkinWeights_lineEdit = QtWidgets.QLineEdit( utils.returnFriendlyPath(self.toolsPath)) self.exportSkinWeights_browseLayout.addWidget( self.exportSkinWeights_lineEdit) self.exportSkinWeights_browseBtn = QtWidgets.QPushButton() self.exportSkinWeights_browseLayout.addWidget( self.exportSkinWeights_browseBtn) self.exportSkinWeights_browseBtn.setMinimumSize(35, 35) self.exportSkinWeights_browseBtn.setMaximumSize(35, 35) icon = QtGui.QIcon( os.path.join(self.iconsPath, "System/fileBrowse.png")) self.exportSkinWeights_browseBtn.setIconSize(QtCore.QSize(30, 30)) self.exportSkinWeights_browseBtn.setIcon(icon) self.exportSkinWeights_browseBtn.clicked.connect( partial(self.exportSkinWeights_fileBrowse)) # scroll area contents self.exportSkinWeights_scrollContents = QtWidgets.QFrame() self.exportSkinWeights_scrollContents.setObjectName("light") # Layout of Container Widget self.exportSkinWeights_VLayout = QtWidgets.QVBoxLayout() # find selected geometry and populate scroll area self.exportSkinWeights_populate() # add scrollArea for selected geo, skinFileName, and checkbox for exporting self.exportSkinWeights_scrollLayout = QtWidgets.QScrollArea() self.exportSkinWeights_widgetLayout.addWidget( self.exportSkinWeights_scrollLayout) self.exportSkinWeights_scrollLayout.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.exportSkinWeights_scrollLayout.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOn) self.exportSkinWeights_scrollLayout.setWidgetResizable(False) self.exportSkinWeights_scrollLayout.setWidget( self.exportSkinWeights_scrollContents) # lastly, export button font = QtGui.QFont() font.setPointSize(8) font.setBold(True) self.exportSkinWeights_exportBtnLayout = QtWidgets.QHBoxLayout() self.exportSkinWeights_widgetLayout.addLayout( self.exportSkinWeights_exportBtnLayout) self.exportSkinWeights_RefreshBtn = QtWidgets.QPushButton("Refresh") self.exportSkinWeights_exportBtnLayout.addWidget( self.exportSkinWeights_RefreshBtn) self.exportSkinWeights_RefreshBtn.setMinimumSize(QtCore.QSize(70, 50)) self.exportSkinWeights_RefreshBtn.setMaximumSize(QtCore.QSize(70, 50)) self.exportSkinWeights_RefreshBtn.setFont(font) self.exportSkinWeights_RefreshBtn.clicked.connect( partial(self.buildExportWeightsUI)) self.exportSkinWeights_RefreshBtn.setObjectName("blueButton") self.exportSkinWeights_ExportBtn = QtWidgets.QPushButton( "EXPORT WEIGHTS") self.exportSkinWeights_exportBtnLayout.addWidget( self.exportSkinWeights_ExportBtn) self.exportSkinWeights_ExportBtn.setMinimumSize(QtCore.QSize(350, 50)) self.exportSkinWeights_ExportBtn.setMaximumSize(QtCore.QSize(350, 50)) self.exportSkinWeights_ExportBtn.setFont(font) self.exportSkinWeights_ExportBtn.clicked.connect( partial(self.exportSkinWeights_doExport)) self.exportSkinWeights_ExportBtn.setObjectName("blueButton") # show window self.exportSkinWeights_Win.show()
def buildAimModeUI(self): """ Builds the Aim Mode interface, finding all modules that have the ability to aim, and listing those modules as well as their current aim status. """ if cmds.window("ART_AimModeWin", exists=True): cmds.deleteUI("ART_AimModeWin", wnd=True) # launch a UI to get the name information self.aimModeWin = QtWidgets.QMainWindow(self.mainUI) # load stylesheet styleSheetFile = utils.returnNicePath( self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss") f = open(styleSheetFile, "r") self.style = f.read() f.close() self.aimModeWin.setStyleSheet(self.style) # size policies mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) # create the main widget self.aimModeWin_mainWidget = QtWidgets.QWidget() self.aimModeWin.setCentralWidget(self.aimModeWin_mainWidget) # set qt object name self.aimModeWin.setObjectName("ART_AimModeWin") self.aimModeWin.setWindowTitle("Aim Mode") # create the mainLayout for the rig creator UI self.aimModeWin_mainLayout = QtWidgets.QVBoxLayout( self.aimModeWin_mainWidget) self.aimModeWin_mainLayout.setContentsMargins(0, 0, 0, 0) self.aimModeWin.resize(400, 250) self.aimModeWin.setSizePolicy(mainSizePolicy) self.aimModeWin.setMinimumSize(QtCore.QSize(400, 250)) self.aimModeWin.setMaximumSize(QtCore.QSize(400, 250)) # create the background image self.aimModeWin_frame = QtWidgets.QFrame() self.aimModeWin_mainLayout.addWidget(self.aimModeWin_frame) # create the layout for the widgets self.aimModeWin_widgetLayout = QtWidgets.QHBoxLayout( self.aimModeWin_frame) self.aimModeWin_widgetLayout.setContentsMargins(5, 5, 5, 5) # add the QListWidget Frame self.aimModeWin_moduleListFrame = QtWidgets.QFrame() self.aimModeWin_moduleListFrame.setMinimumSize(QtCore.QSize(275, 200)) self.aimModeWin_moduleListFrame.setMaximumSize(QtCore.QSize(275, 200)) self.aimModeWin_moduleListFrame.setContentsMargins(20, 0, 20, 0) # create the list widget self.aimModeWin_moduleList = QtWidgets.QListWidget( self.aimModeWin_moduleListFrame) self.aimModeWin_widgetLayout.addWidget(self.aimModeWin_moduleListFrame) self.aimModeWin_moduleList.setMinimumSize(QtCore.QSize(265, 200)) self.aimModeWin_moduleList.setMaximumSize(QtCore.QSize(265, 200)) self.aimModeWin_moduleList.setSelectionMode( QtWidgets.QAbstractItemView.MultiSelection) self.aimModeWin_moduleList.setSpacing(3) # add the layout for the buttons self.aimModeWin_buttonLayoutAll = QtWidgets.QVBoxLayout() self.aimModeWin_widgetLayout.addLayout(self.aimModeWin_buttonLayoutAll) self.aimModeWin_buttonLayoutAll.setContentsMargins(5, 20, 5, 20) # add the selection buttons self.aimModeWin_selectionButtonLayout = QtWidgets.QVBoxLayout() self.aimModeWin_buttonLayoutAll.addLayout( self.aimModeWin_selectionButtonLayout) self.aimModeWin_selectAllButton = QtWidgets.QPushButton("Select All") self.aimModeWin_selectAllButton.setMinimumSize(QtCore.QSize(115, 25)) self.aimModeWin_selectAllButton.setMaximumSize(QtCore.QSize(115, 25)) self.aimModeWin_selectionButtonLayout.addWidget( self.aimModeWin_selectAllButton) self.aimModeWin_selectAllButton.clicked.connect( self.aimModeWin_moduleList.selectAll) self.aimModeWin_selectAllButton.setObjectName("blueButton") self.aimModeWin_selectNoneButton = QtWidgets.QPushButton( "Clear Selection") self.aimModeWin_selectNoneButton.setMinimumSize(QtCore.QSize(115, 25)) self.aimModeWin_selectNoneButton.setMaximumSize(QtCore.QSize(115, 25)) self.aimModeWin_selectionButtonLayout.addWidget( self.aimModeWin_selectNoneButton) self.aimModeWin_selectNoneButton.clicked.connect( self.aimModeWin_moduleList.clearSelection) self.aimModeWin_selectNoneButton.setObjectName("blueButton") # spacer spacerItem = QtWidgets.QSpacerItem(20, 80, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.aimModeWin_selectionButtonLayout.addItem(spacerItem) # add the buttons for reset settings and reset transforms self.aimModeWin_turnOnAim = QtWidgets.QPushButton("On") self.aimModeWin_turnOnAim.setMinimumSize(QtCore.QSize(115, 25)) self.aimModeWin_turnOnAim.setMaximumSize(QtCore.QSize(115, 25)) self.aimModeWin_selectionButtonLayout.addWidget( self.aimModeWin_turnOnAim) self.aimModeWin_turnOnAim.setToolTip( "Turn on Aim Mode for selected modules.") self.aimModeWin_turnOnAim.clicked.connect( partial(self.aimModeUI_Toggle, True)) self.aimModeWin_turnOnAim.setObjectName("blueButton") self.aimModeWin_turnOffAim = QtWidgets.QPushButton("Off") self.aimModeWin_turnOffAim.setMinimumSize(QtCore.QSize(115, 25)) self.aimModeWin_turnOffAim.setMaximumSize(QtCore.QSize(115, 25)) self.aimModeWin_selectionButtonLayout.addWidget( self.aimModeWin_turnOffAim) self.aimModeWin_turnOffAim.setToolTip( "Turn off Aim Mode for selected modules.") self.aimModeWin_turnOffAim.clicked.connect( partial(self.aimModeUI_Toggle, False)) self.aimModeWin_turnOffAim.setObjectName("blueButton") # populate the list widget modules = utils.returnRigModules() for module in modules: # get module name moduleName = cmds.getAttr(module + ".moduleName") # figure out if the module supports aimMode canAim = False if cmds.objExists(module + ".canAim"): canAim = cmds.getAttr(module + ".canAim") # see if it is currently in aimMode aimMode = cmds.getAttr(module + ".aimMode") # if it does, add it to the listwidget if canAim: # font headerFont = QtGui.QFont() headerFont.setPointSize(10) headerFont.setBold(True) # create the listWidgetItem pixmap = QtGui.QPixmap(10, 10) pixmap.fill(QtGui.QColor(0, 255, 0)) icon = QtGui.QIcon(pixmap) pixmapOff = QtGui.QPixmap(10, 10) pixmapOff.fill(QtGui.QColor(255, 0, 0)) iconOff = QtGui.QIcon(pixmapOff) item = QtWidgets.QListWidgetItem(iconOff, moduleName) item.setFont(headerFont) item.setTextAlignment(QtCore.Qt.AlignCenter) item.setData(QtCore.Qt.UserRole, [icon, iconOff]) if aimMode: item.setIcon(icon) self.aimModeWin_moduleList.addItem(item) # show the window self.aimModeWin.show()
def buildUI(self): if cmds.window("pyART_ImportMotionWIN", exists=True): cmds.deleteUI("pyART_ImportMotionWIN", wnd=True) #create the main window self.mainWin = QtWidgets.QMainWindow(self.pickerUI) #create the main widget self.mainWidget = QtWidgets.QWidget() self.mainWin.setCentralWidget(self.mainWidget) #create the mainLayout self.layout = QtWidgets.QVBoxLayout(self.mainWidget) #load stylesheet styleSheetFile = utils.returnNicePath( self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/animPicker.qss") f = open(styleSheetFile, "r") self.style = f.read() f.close() self.mainWin.setStyleSheet(self.style) self.mainWin.setMinimumSize(QtCore.QSize(600, 350)) self.mainWin.setMaximumSize(QtCore.QSize(600, 350)) self.mainWin.resize(600, 350) #set qt object name self.mainWin.setObjectName("pyART_ImportMotionWIN") self.mainWin.setWindowTitle("Import Motion") #tabs self.importTabs = QtWidgets.QTabWidget() self.layout.addWidget(self.importTabs) #style sheet stylesheet = """ QTabBar::tab { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(19,132,183), stop:1 rgb(30,30,30)); width: 100px; padding-left: -10px; } QTabBar::tab:selected { background-color: rgb(14,100,143); border: 2px solid black; } QTabBar::tab:hover { background: rgb(19,132,183); } QTabBar::tab:!selected { margin-top: 5px; } QTabWidget::pane { border-top: 2px solid rgb(19,132,183); border-left: 2px solid rgb(19,132,183); border-right: 2px solid rgb(19,132,183); border-bottom: 2px solid rgb(19,132,183); } """ self.importTabs.setStyleSheet(stylesheet) #FBX Tab self.fbxImportTab = QtWidgets.QWidget() self.importTabs.addTab(self.fbxImportTab, "FBX") #Anim Curve Tab self.animImportTab = QtWidgets.QWidget() self.importTabs.addTab(self.animImportTab, "Animation") #======================================================================= #======================================================================= #======================================================================= #======================================================================= # #FBX TAB #======================================================================= #======================================================================= #======================================================================= #======================================================================= #horizontal layout self.fbxMainLayout = QtWidgets.QHBoxLayout(self.fbxImportTab) #LEFT SIDE #module list widget self.fbxModuleList = QtWidgets.QListWidget() self.fbxMainLayout.addWidget(self.fbxModuleList) self.fbxModuleList.setMinimumSize(QtCore.QSize(300, 280)) self.fbxModuleList.setMaximumSize(QtCore.QSize(300, 280)) self.fbxModuleList.setSpacing(15) self.fbxModuleList.setSelectionMode( QtWidgets.QAbstractItemView.NoSelection) #RIGHT SIDE self.fbxRightLayout = QtWidgets.QVBoxLayout() self.fbxMainLayout.addLayout(self.fbxRightLayout) self.fbxCharacterCombo = QtWidgets.QComboBox() self.fbxRightLayout.addWidget(self.fbxCharacterCombo) self.fbxCharacterCombo.setMinimumSize(QtCore.QSize(250, 50)) self.fbxCharacterCombo.setMaximumSize(QtCore.QSize(250, 50)) self.fbxCharacterCombo.setIconSize(QtCore.QSize(45, 45)) self.fbxCharacterCombo.currentIndexChanged.connect( partial(self.findCharacterModules)) self.fbxPathLayout = QtWidgets.QHBoxLayout() self.fbxRightLayout.addLayout(self.fbxPathLayout) self.fbxFilePath = QtWidgets.QLineEdit() self.fbxFilePath.setMinimumWidth(210) self.fbxFilePath.setMaximumWidth(210) self.fbxPathLayout.addWidget(self.fbxFilePath) self.fbxFilePath.setPlaceholderText("fbx file..") browseBtn = QtWidgets.QPushButton() browseBtn.setMinimumSize(25, 25) browseBtn.setMaximumSize(25, 25) self.fbxPathLayout.addWidget(browseBtn) icon = QtGui.QIcon( utils.returnNicePath(self.iconsPath, "System/fileBrowse.png")) browseBtn.setIconSize(QtCore.QSize(25, 25)) browseBtn.setIcon(icon) browseBtn.clicked.connect(self.fbxFileBrowse) self.frameOffsetLayout = QtWidgets.QHBoxLayout() self.fbxRightLayout.addLayout(self.frameOffsetLayout) frameOffset = QtWidgets.QLabel("Frame Offset:") frameOffset.setStyleSheet("background: transparent; font: bold;") self.frameOffsetLayout.addWidget(frameOffset) self.frameOffsetField = QtWidgets.QSpinBox() self.frameOffsetField.setButtonSymbols( QtWidgets.QAbstractSpinBox.NoButtons) self.frameOffsetField.setRange(-1000, 10000) self.frameOffsetLayout.addWidget(self.frameOffsetField) #option to strip namespace self.stripNamespace = QtWidgets.QCheckBox("Strip Incoming Namespace") self.stripNamespace.setToolTip( "If the incoming FBX has a namespace, checking this\noption will strip that namespace upon import" ) self.stripNamespace.setChecked(True) self.fbxRightLayout.addWidget(self.stripNamespace) #Save/Load Settings saveLoadLayout = QtWidgets.QHBoxLayout() self.fbxRightLayout.addLayout(saveLoadLayout) saveSettingsBtn = QtWidgets.QPushButton("Save Settings") saveSettingsBtn.setMinimumSize(120, 30) saveSettingsBtn.setMaximumSize(120, 30) icon = QtGui.QIcon( utils.returnNicePath(self.iconsPath, "System/save.png")) saveSettingsBtn.setIconSize(QtCore.QSize(25, 25)) saveSettingsBtn.setIcon(icon) saveLoadLayout.addWidget(saveSettingsBtn) saveSettingsBtn.setObjectName("blueButton") saveSettingsBtn.setToolTip("Save out module import settings") saveSettingsBtn.clicked.connect(self.saveSettings) loadSettingsBtn = QtWidgets.QPushButton("Load Settings") loadSettingsBtn.setMinimumSize(120, 30) loadSettingsBtn.setMaximumSize(120, 30) icon = QtGui.QIcon( utils.returnNicePath(self.iconsPath, "System/load.png")) loadSettingsBtn.setIconSize(QtCore.QSize(25, 25)) loadSettingsBtn.setIcon(icon) saveLoadLayout.addWidget(loadSettingsBtn) loadSettingsBtn.setObjectName("blueButton") loadSettingsBtn.setToolTip("Load and set module import settings") loadSettingsBtn.clicked.connect(self.loadSettings) #SPACER! self.fbxRightLayout.addSpacerItem( QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)) #Button self.importFBXbutton = QtWidgets.QPushButton("Import") self.fbxRightLayout.addWidget(self.importFBXbutton) self.importFBXbutton.setObjectName("blueButton") self.importFBXbutton.setMinimumHeight(50) self.importFBXbutton.clicked.connect(self.fbxImport) #show window self.mainWin.show() #populate UI self.findCharacters() self.findCharacterModules()
def buildUI(self): if cmds.window("ART_PinModulesWin", exists = True): cmds.deleteUI("ART_PinModulesWin", wnd = True) #launch a UI to get the name information self.window = QtWidgets.QMainWindow(self.mainUI) #load stylesheet styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss") f = open(styleSheetFile, "r") self.style = f.read() f.close() self.window.setStyleSheet(self.style) #size policies mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) #create the main widget self.mainWidget = QtWidgets.QWidget() self.window.setCentralWidget(self.mainWidget) #set qt object name self.window.setObjectName("ART_PinModulesWin") self.window.setWindowTitle("Pin Modules") #create the mainLayout for the rig creator UI self.mainLayout = QtWidgets.QVBoxLayout(self.mainWidget) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.window.resize(400, 250) self.window.setSizePolicy(mainSizePolicy) self.window.setMinimumSize(QtCore.QSize( 400, 250 )) self.window.setMaximumSize(QtCore.QSize( 400, 250 )) #create the background image self.frame = QtWidgets.QFrame() self.mainLayout.addWidget(self.frame) #create the layout for the widgets self.widgetLayout = QtWidgets.QHBoxLayout(self.frame) self.widgetLayout.setContentsMargins(5, 5, 5, 5) #left side == list of modules in scene. for each item in list, will do something similar to aim mode, where we will toggle an icon for pin state self.moduleList = QtWidgets.QListWidget() self.widgetLayout.addWidget(self.moduleList) self.moduleList.setMinimumSize(QtCore.QSize( 265, 200 )) self.moduleList.setMaximumSize(QtCore.QSize( 265, 200 )) self.moduleList.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection) self.moduleList.setSpacing(3) #right side layout == select all, clear selection, Pin Selected buttons self.buttonLayout = QtWidgets.QVBoxLayout() self.widgetLayout.addLayout(self.buttonLayout) self.buttonLayout.setContentsMargins(5, 20, 5, 20) #add the selection buttons self.selectAllButton = QtWidgets.QPushButton("Select All") self.selectAllButton.setMinimumSize(QtCore.QSize( 115, 25 )) self.selectAllButton.setMaximumSize(QtCore.QSize( 115, 25 )) self.buttonLayout.addWidget(self.selectAllButton) self.selectAllButton.clicked.connect(self.moduleList.selectAll) self.selectAllButton.setObjectName("blueButton") self.selectNoneButton = QtWidgets.QPushButton("Clear Selection") self.selectNoneButton.setMinimumSize(QtCore.QSize( 115, 25 )) self.selectNoneButton.setMaximumSize(QtCore.QSize( 115, 25 )) self.buttonLayout.addWidget(self.selectNoneButton) self.selectNoneButton.clicked.connect(self.moduleList.clearSelection) self.selectNoneButton.setObjectName("blueButton") #spacer spacerItem = QtWidgets.QSpacerItem(20, 80, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.buttonLayout.addItem(spacerItem) #add the buttons for reset settings and reset transforms self.pinBtn = QtWidgets.QPushButton("Pin Selected") self.pinBtn.setMinimumSize(QtCore.QSize( 115, 25 )) self.pinBtn.setMaximumSize(QtCore.QSize( 115, 25 )) self.buttonLayout.addWidget(self.pinBtn) self.pinBtn.setToolTip("Pin the selected modules so that parent module movements do not effect the pinned module") self.pinBtn.clicked.connect(partial(self.toggleLock, True)) self.pinBtn.setObjectName("blueButton") self.unpinBtn = QtWidgets.QPushButton("Unpin Selected") self.unpinBtn.setMinimumSize(QtCore.QSize( 115, 25 )) self.unpinBtn.setMaximumSize(QtCore.QSize( 115, 25 )) self.buttonLayout.addWidget(self.unpinBtn) self.unpinBtn.setToolTip("Unpin modules to resume normal module behavior") self.unpinBtn.clicked.connect(partial(self.toggleLock, False)) self.unpinBtn.setObjectName("blueButton") #populate the list widget modules = utils.returnRigModules() for module in modules: #get module name moduleName = cmds.getAttr(module + ".moduleName") #font headerFont = QtGui.QFont() headerFont.setPointSize(10) headerFont.setBold(True) #create the listWidgetItem icon = QtGui.QIcon(os.path.join(self.iconsPath, "System/locked.png")) iconOff = QtGui.QIcon(os.path.join(self.iconsPath, "System/unlocked.png")) item = QtWidgets.QListWidgetItem(iconOff, " " + moduleName) item.setFont(headerFont) item.setData(QtCore.Qt.UserRole, [icon, iconOff]) pinState = cmds.getAttr(module + ".pinned") if pinState: item.setIcon(icon) self.moduleList.addItem(item) #show the window self.window.show()