def mousePressEvent(self, event): # handle an internal move # start a drag event if event.button() == QtCore.Qt.LeftButton and self.dragDropRect( ).contains(event.pos()): # create the pixmap pixmap = QtWidgets.QPixmap.grabWidget(self, self.rect()) # create the mimedata mimeData = QtCore.QMimeData() mimeData.setText('ItemTitle::%s' % (self.title())) # create the drag drag = QtWidgets.QDrag(self) drag.setMimeData(mimeData) drag.setPixmap(pixmap) drag.setHotSpot(event.pos()) if not drag.exec_(): self._accordianWidget.emitItemDragFailed(self) event.accept() # determine if the expand/collapse should occur elif event.button( ) == QtCore.Qt.LeftButton and self.expandCollapseRect().contains( event.pos()): self._clicked = True event.accept() else: event.ignore()
def get_show_repr(): dict_ = {} dict_['display'] = False dict_['dockable'] = True dict_['floating'] = True dict_['area'] = None dict_['x'] = 0 dict_['y'] = 0 dict_['width'] = 400 dict_['height'] = 150 _ui = get_ui() if _ui is None: return dict_ if _ui.isVisible() is False: return dict_ dict_['display'] = True dict_['dockable'] = _ui.isDockable() dict_['floating'] = _ui.isFloating() dict_['area'] = _ui.dockArea() if dict_['dockable'] is True: dock_dtrl = _ui.parent() _pos = dock_dtrl.mapToGlobal(QtCore.QPoint(0, 0)) else: _pos = _ui.pos() _sz = _ui.geometry().size() dict_['x'] = _pos.x() dict_['y'] = _pos.y() dict_['width'] = _sz.width() dict_['height'] = _sz.height() return dict_
def setupUi(self, re_manager): re_manager.setObjectName("re_manager") re_manager.resize(702, 722) self.centralwidget = QtWidgets.QWidget(re_manager) self.centralwidget.setEnabled(True) self.centralwidget.setObjectName("centralwidget") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout_2.setObjectName("verticalLayout_2") self.animsTreeView = QtWidgets.QTreeView(self.centralwidget) self.animsTreeView.setObjectName("animsTreeView") self.verticalLayout_2.addWidget(self.animsTreeView) self.animLoadSelectedBtn = QtWidgets.QPushButton(self.centralwidget) self.animLoadSelectedBtn.setObjectName("animLoadSelectedBtn") self.verticalLayout_2.addWidget(self.animLoadSelectedBtn) self.timeEditorBtn = QtWidgets.QPushButton(self.centralwidget) self.timeEditorBtn.setObjectName("timeEditorBtn") self.verticalLayout_2.addWidget(self.timeEditorBtn) self.loadSequencerBtn = QtWidgets.QPushButton(self.centralwidget) self.loadSequencerBtn.setObjectName("loadSequencerBtn") self.verticalLayout_2.addWidget(self.loadSequencerBtn) self.groupBox = QtWidgets.QGroupBox(self.centralwidget) self.groupBox.setObjectName("groupBox") self.verticalLayout = QtWidgets.QVBoxLayout(self.groupBox) self.verticalLayout.setObjectName("verticalLayout") self.renameBonesBtn = QtWidgets.QPushButton(self.groupBox) self.renameBonesBtn.setObjectName("renameBonesBtn") self.verticalLayout.addWidget(self.renameBonesBtn) self.injectAnimBtn = QtWidgets.QPushButton(self.groupBox) self.injectAnimBtn.setObjectName("injectAnimBtn") self.verticalLayout.addWidget(self.injectAnimBtn) self.verticalLayout_2.addWidget(self.groupBox) re_manager.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(re_manager) self.menubar.setGeometry(QtCore.QRect(0, 0, 702, 21)) self.menubar.setObjectName("menubar") self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") self.menuRecent_Files = QtWidgets.QMenu(self.menuFile) self.menuRecent_Files.setObjectName("menuRecent_Files") self.menuAbout = QtWidgets.QMenu(self.menubar) self.menuAbout.setObjectName("menuAbout") re_manager.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(re_manager) self.statusbar.setObjectName("statusbar") re_manager.setStatusBar(self.statusbar) self.actionImport_motlist = QtWidgets.QAction(re_manager) self.actionImport_motlist.setCheckable(False) self.actionImport_motlist.setObjectName("actionImport_motlist") self.actionAbout = QtWidgets.QAction(re_manager) self.actionAbout.setObjectName("actionAbout") self.menuFile.addAction(self.actionImport_motlist) self.menuFile.addAction(self.menuRecent_Files.menuAction()) self.menuAbout.addAction(self.actionAbout) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuAbout.menuAction()) self.retranslateUi(re_manager) QtCore.QMetaObject.connectSlotsByName(re_manager)
def selectInScene(self): """ Call back function. Triggered when selction changed. """ sel = cmds.ls(sl=1, l=1, type='transform') rows = self.treeWidget.topLevelItemCount() cols = self.treeWidget.columnCount() for i in range(0, rows): self.treeWidget.takeTopLevelItem(0) if not sel: return customAttrList = cmds.listAttr(sel[-1], ud=1) attrList = list() attrList = channels.CHANNELNAMES if customAttrList: attrList = channels.CHANNELNAMES + customAttrList self.mapperSlider = QtCore.QSignalMapper() i = 0 for attr in attrList: if attr == 'attrTag': continue sliderIdA = str(i) + '|' item = QtWidgets.QTreeWidgetItem(self.treeWidget) ## Column 0 item.setText(0, attr) for col in range(1, cols): sliderId = sliderIdA + str(col) ## Column 1, 2, 3 slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self.treeWidget) self.treeWidget.setItemWidget(item, col, slider) slider.setMaximumWidth(self.sliderRange) slider.setMaximum(self.sliderRange) slider.setPageStep(self.sliderRange) slider.setStyleSheet(STYLESHEET) self.mapperSlider.setMapping(slider, sliderId) slider.sliderReleased.connect(self.mapperSlider.map) i += 1 self.mapperSlider.mapped['QString'].connect(self.snapToEnd) self.readCurrentStatus(sel[-1])
def __drawTriangle(self, painter, x, y): brush = QtGui.QBrush(QtGui.QColor(255, 255, 255, 160), QtCore.Qt.SolidPattern) if not self.isCollapsed(): tl, tr, tp = (QtCore.QPoint(x + 9, y + 8), QtCore.QPoint(x + 19, y + 8), QtCore.QPoint(x + 14, y + 13.0)) points = [tl, tr, tp] triangle = QtGui.QPolygon(points) else: tl, tr, tp = QtCore.QPoint(x + 11, y + 6), QtCore.QPoint( x + 16, y + 11), QtCore.QPoint(x + 11, y + 16.0) points = [tl, tr, tp] triangle = QtGui.QPolygon(points) currentBrush = painter.brush() painter.setBrush(brush) painter.drawPolygon(triangle) painter.setBrush(currentBrush)
def setupUi(self): self.setObjectName("controlFactory") sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) # layouts mainLayout = QtWidgets.QVBoxLayout(self) vLayout_addCurve = QtWidgets.QVBoxLayout() hLayout_addCurve = QtWidgets.QHBoxLayout() vLayout_copyCurve = QtWidgets.QVBoxLayout() hLayout_copyCurve = QtWidgets.QHBoxLayout() vLayout_removeCurve = QtWidgets.QVBoxLayout() hLayout_removeCurve = QtWidgets.QHBoxLayout() vLayout_color = QtWidgets.QVBoxLayout() hLayout_color = QtWidgets.QHBoxLayout() vLayout_scale = QtWidgets.QVBoxLayout() hLayout_scale = QtWidgets.QHBoxLayout() vLayout_tweak = QtWidgets.QVBoxLayout() hLayout_tweak = QtWidgets.QHBoxLayout() vLayout_addGroups = QtWidgets.QVBoxLayout() hLayout_addOffsetGroups = QtWidgets.QHBoxLayout() vLayout_addCurve.addLayout(hLayout_addCurve) vLayout_copyCurve.addLayout(hLayout_copyCurve) vLayout_removeCurve.addLayout(hLayout_removeCurve) vLayout_color.addLayout(hLayout_color) vLayout_scale.addLayout(hLayout_scale) vLayout_tweak.addLayout(hLayout_tweak) vLayout_addGroups.addLayout(hLayout_addOffsetGroups) # buttons pb_addCurve = QtWidgets.QPushButton() pb_copyCurve = QtWidgets.QPushButton() pb_copyShapes = QtWidgets.QPushButton("Copy ControlShapes") pb_removeCurve = QtWidgets.QPushButton() pb_removeShapes = QtWidgets.QPushButton("Remove ControlShapes") pb_color = QtWidgets.QPushButton() pb_scale = QtWidgets.QPushButton() pb_tweak = QtWidgets.QPushButton() pb_addOffsetGroups = QtWidgets.QPushButton() pb_addGroups = QtWidgets.QPushButton("Add zero grp") pb_N = QtWidgets.QPushButton("N") pb_R = QtWidgets.QPushButton("R") pb_T = QtWidgets.QPushButton("T") pb_default = QtWidgets.QPushButton("X") pb_plusX = QtWidgets.QPushButton("+") pb_minusX = QtWidgets.QPushButton("-") pb_plusY = QtWidgets.QPushButton("+") pb_minusY = QtWidgets.QPushButton("-") pb_plusZ = QtWidgets.QPushButton("+") pb_minusZ = QtWidgets.QPushButton("-") pb_scaleDown = QtWidgets.QPushButton("-") pb_scaleUp = QtWidgets.QPushButton("+") pb_N.setSizePolicy(sizePolicy) pb_R.setSizePolicy(sizePolicy) pb_T.setSizePolicy(sizePolicy) pb_default.setSizePolicy(sizePolicy) pb_addCurve.setMaximumSize(QtCore.QSize(25, 25)) pb_copyCurve.setMaximumSize(QtCore.QSize(25, 25)) pb_removeCurve.setMaximumSize(QtCore.QSize(25, 25)) pb_color.setMaximumSize(QtCore.QSize(25, 25)) pb_scale.setMaximumSize(QtCore.QSize(25, 25)) pb_tweak.setMaximumSize(QtCore.QSize(25, 25)) pb_addOffsetGroups.setMaximumSize(QtCore.QSize(25, 25)) pb_plusX.setMaximumSize(QtCore.QSize(30, 16777215)) pb_minusX.setMaximumSize(QtCore.QSize(30, 16777215)) pb_plusY.setMaximumSize(QtCore.QSize(30, 16777215)) pb_minusY.setMaximumSize(QtCore.QSize(30, 16777215)) pb_minusZ.setMaximumSize(QtCore.QSize(30, 16777215)) pb_plusZ.setMaximumSize(QtCore.QSize(30, 16777215)) pb_scaleDown.setMaximumSize(QtCore.QSize(30, 16777215)) pb_scaleUp.setMaximumSize(QtCore.QSize(30, 16777215)) pb_addCurve.setMinimumSize(QtCore.QSize(25, 25)) pb_copyCurve.setMinimumSize(QtCore.QSize(25, 25)) pb_removeCurve.setMinimumSize(QtCore.QSize(25, 25)) pb_color.setMinimumSize(QtCore.QSize(25, 25)) pb_scale.setMinimumSize(QtCore.QSize(25, 25)) pb_tweak.setMinimumSize(QtCore.QSize(25, 25)) pb_addOffsetGroups.setMinimumSize(QtCore.QSize(25, 25)) # labels label_addCurve = QtWidgets.QLabel("Add Control Curve") label_addCurve.setFrameShape(QtWidgets.QFrame.NoFrame) label_copyCurve = QtWidgets.QLabel("Copy Control Curve") label_removeCurve = QtWidgets.QLabel("Remove Control Curve(s)") label_color = QtWidgets.QLabel("Color") label_scale = QtWidgets.QLabel("Scale") label_minScale = QtWidgets.QLabel("Min") label_maxScale = QtWidgets.QLabel("Max") label_title = QtWidgets.QLabel("Value") label_sliderValue = QtWidgets.QLabel("") label_rotation = QtWidgets.QLabel("Rotation") label_rtX = QtWidgets.QLabel("Rotate X") label_rtY = QtWidgets.QLabel("Rotate Y") label_rtZ = QtWidgets.QLabel("Rotate Z") label_addGroups = QtWidgets.QLabel("Add offset groups") label_minScale.setAlignment(QtCore.Qt.AlignCenter) label_maxScale.setAlignment(QtCore.Qt.AlignCenter) # minimize widgets widget_addCurve = QtWidgets.QWidget() widget_copy = QtWidgets.QWidget() widget_remove = QtWidgets.QWidget() widget_color = QtWidgets.QWidget() widget_scale = QtWidgets.QWidget() widget_tweak = QtWidgets.QWidget() widget_addGroups = QtWidgets.QWidget() vLayout_addCurve.addWidget(widget_addCurve) vLayout_copyCurve.addWidget(widget_copy) vLayout_removeCurve.addWidget(widget_remove) vLayout_color.addWidget(widget_color) vLayout_scale.addWidget(widget_scale) vLayout_tweak.addWidget(widget_tweak) vLayout_addGroups.addWidget(widget_addGroups) # checkbox cb_shapeOnly = QtWidgets.QCheckBox("ControlShape Only") cb_viewport = QtWidgets.QCheckBox("Viewport") cb_outliner = QtWidgets.QCheckBox("Outliner") cb_nonUniform = QtWidgets.QCheckBox("Non-uniform") cb_x = QtWidgets.QCheckBox("x") cb_y = QtWidgets.QCheckBox("y") cb_z = QtWidgets.QCheckBox("z") cb_zero = QtWidgets.QCheckBox("zero") cb_sdk = QtWidgets.QCheckBox("sdk") cb_offset = QtWidgets.QCheckBox("offset") cb_parent = QtWidgets.QCheckBox("parent") # line edits le_x = QtWidgets.QLineEdit() le_y = QtWidgets.QLineEdit() le_z = QtWidgets.QLineEdit() le_minScale = QtWidgets.QLineEdit() le_maxScale = QtWidgets.QLineEdit() le_minScale.setMaximumSize(QtCore.QSize(30, 16777215)) le_maxScale.setMaximumSize(QtCore.QSize(30, 16777215)) # slider hSlider_scaleFactor = QtWidgets.QSlider() # spacers spacerStart = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerEnd = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) # add buttons to title layouts hLayout_addCurve.addWidget(pb_addCurve) hLayout_copyCurve.addWidget(pb_copyCurve) hLayout_removeCurve.addWidget(pb_removeCurve) hLayout_color.addWidget(pb_color) hLayout_scale.addWidget(pb_scale) hLayout_tweak.addWidget(pb_tweak) hLayout_addOffsetGroups.addWidget(pb_addOffsetGroups) # add labels to title layouts hLayout_addCurve.addWidget(label_addCurve) hLayout_copyCurve.addWidget(label_copyCurve) hLayout_removeCurve.addWidget(label_removeCurve) hLayout_color.addWidget(label_color) hLayout_scale.addWidget(label_scale) hLayout_tweak.addWidget(label_rotation) hLayout_addOffsetGroups.addWidget(label_addGroups) # addCurve layout vLayout_inner_addCurve = QtWidgets.QVBoxLayout(widget_addCurve) gLayout_addCurve = QtWidgets.QGridLayout() vLayout_inner_addCurve.addLayout(gLayout_addCurve) vLayout_inner_addCurve.addWidget(cb_shapeOnly) # copyCurve layout vLayout_copy = QtWidgets.QVBoxLayout(widget_copy) vLayout_copy.addWidget(pb_copyShapes) # removeCurve layout vLayout_remove = QtWidgets.QVBoxLayout(widget_remove) vLayout_remove.addWidget(pb_removeShapes) # color layout vLayout_colorWidget = QtWidgets.QVBoxLayout(widget_color) gLayout_color = QtWidgets.QGridLayout() gLayout_color.addWidget(pb_N, 0, 0, 1, 1) gLayout_color.addWidget(pb_R, 0, 2, 1, 1) gLayout_color.addWidget(pb_T, 0, 1, 1, 1) gLayout_color.addWidget(pb_default, 0, 3, 1, 1) hLayout_colorType = QtWidgets.QHBoxLayout() hLayout_colorType.addWidget(cb_viewport) hLayout_colorType.addWidget(cb_outliner) vLayout_colorWidget.addLayout(hLayout_colorType) vLayout_colorWidget.addLayout(gLayout_color) # scale layout vLayout_scaleWidget = QtWidgets.QVBoxLayout(widget_scale) vLayout_nonUniform = QtWidgets.QVBoxLayout() vLayout_nonUniform.addWidget(cb_nonUniform) hLayout_nonUniform = QtWidgets.QHBoxLayout() hLayout_nonUniform.setContentsMargins(30, -1, -1, -1) hLayout_nonUniform.addWidget(cb_x) hLayout_nonUniform.addWidget(cb_y) hLayout_nonUniform.addWidget(cb_z) vLayout_nonUniform.addLayout(hLayout_nonUniform) hLayout_upDown = QtWidgets.QHBoxLayout() vLayout_scaleFactor = QtWidgets.QVBoxLayout() hLayout_scaleFactor = QtWidgets.QHBoxLayout() vLayout_min = QtWidgets.QVBoxLayout() vLayout_min.addWidget(label_minScale) vLayout_min.addWidget(le_minScale) hLayout_scaleFactor.addLayout(vLayout_min) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) hLayout_scaleFactor.addItem(spacerItem) vLayout_sliderValue = QtWidgets.QVBoxLayout() vLayout_sliderValue.addWidget(label_title) vLayout_sliderValue.addWidget(label_sliderValue) hLayout_scaleFactor.addLayout(vLayout_sliderValue) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) hLayout_scaleFactor.addItem(spacerItem) vLayout_max = QtWidgets.QVBoxLayout() vLayout_max.addWidget(label_maxScale) vLayout_max.addWidget(le_maxScale) hLayout_scaleFactor.addLayout(vLayout_max) vLayout_scaleFactor.addLayout(hLayout_scaleFactor) hSlider_scaleFactor.setMinimum(1) hSlider_scaleFactor.setOrientation(QtCore.Qt.Horizontal) hSlider_scaleFactor.setTickPosition(QtWidgets.QSlider.NoTicks) vLayout_scaleFactor.addWidget(hSlider_scaleFactor) hLayout_upDown.addLayout(vLayout_scaleFactor) vLayout_btn = QtWidgets.QVBoxLayout() spacer = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) vLayout_btn.addItem(spacer) hLayout_btn = QtWidgets.QHBoxLayout() hLayout_btn.addWidget(pb_scaleDown) hLayout_btn.addWidget(pb_scaleUp) vLayout_btn.addLayout(hLayout_btn) hLayout_upDown.addLayout(vLayout_btn) vLayout_scaleWidget.addLayout(vLayout_nonUniform) vLayout_scaleWidget.addLayout(hLayout_upDown) # tweak layout gLayout_tweak = QtWidgets.QGridLayout(widget_tweak) gLayout_tweak.addItem(spacerStart, 0, 0, 1, 1) gLayout_tweak.addWidget(pb_plusX, 0, 4, 1, 1) gLayout_tweak.addWidget(le_x, 0, 2, 1, 1) gLayout_tweak.addWidget(pb_minusX, 0, 3, 1, 1) gLayout_tweak.addWidget(label_rtX, 0, 1, 1, 1) gLayout_tweak.addItem(spacerEnd, 0, 5, 1, 1) gLayout_tweak.addWidget(label_rtY, 1, 1, 1, 1) gLayout_tweak.addWidget(label_rtZ, 2, 1, 1, 1) gLayout_tweak.addWidget(le_y, 1, 2, 1, 1) gLayout_tweak.addWidget(le_z, 2, 2, 1, 1) gLayout_tweak.addWidget(pb_minusY, 1, 3, 1, 1) gLayout_tweak.addWidget(pb_minusZ, 2, 3, 1, 1) gLayout_tweak.addWidget(pb_plusY, 1, 4, 1, 1) gLayout_tweak.addWidget(pb_plusZ, 2, 4, 1, 1) # add groups layout vLayout_addOffsetGroups = QtWidgets.QVBoxLayout(widget_addGroups) hLayout_addGroups = QtWidgets.QHBoxLayout() hLayout_addGroups.addWidget(cb_zero) hLayout_addGroups.addWidget(cb_sdk) hLayout_addGroups.addWidget(cb_offset) hLayout_addGroups.addWidget(cb_parent) vLayout_addOffsetGroups.addLayout(hLayout_addGroups) vLayout_addOffsetGroups.addWidget(pb_addGroups) line_1 = QtWidgets.QFrame() line_1.setFrameShape(QtWidgets.QFrame.HLine) line_1.setFrameShadow(QtWidgets.QFrame.Sunken) line_2 = QtWidgets.QFrame() line_2.setFrameShape(QtWidgets.QFrame.HLine) line_2.setFrameShadow(QtWidgets.QFrame.Sunken) line_3 = QtWidgets.QFrame() line_3.setFrameShape(QtWidgets.QFrame.HLine) line_3.setFrameShadow(QtWidgets.QFrame.Sunken) line_4 = QtWidgets.QFrame() line_4.setFrameShape(QtWidgets.QFrame.HLine) line_4.setFrameShadow(QtWidgets.QFrame.Sunken) line_5 = QtWidgets.QFrame() line_5.setFrameShape(QtWidgets.QFrame.HLine) line_5.setFrameShadow(QtWidgets.QFrame.Sunken) line_6 = QtWidgets.QFrame() line_6.setFrameShape(QtWidgets.QFrame.HLine) line_6.setFrameShadow(QtWidgets.QFrame.Sunken) mainLayout.addLayout(vLayout_addCurve) mainLayout.addWidget(line_1) mainLayout.addLayout(vLayout_copyCurve) mainLayout.addWidget(line_2) mainLayout.addLayout(vLayout_removeCurve) mainLayout.addWidget(line_3) mainLayout.addLayout(vLayout_color) mainLayout.addWidget(line_4) mainLayout.addLayout(vLayout_scale) mainLayout.addWidget(line_5) mainLayout.addLayout(vLayout_tweak) mainLayout.addWidget(line_6) mainLayout.addLayout(vLayout_addGroups) self.data = { 'buttons': { 'addCurve': pb_addCurve, 'copyCurve': pb_copyCurve, 'copyShapes': pb_copyShapes, 'removeCurve': pb_removeCurve, 'removeShapes': pb_removeShapes, 'color': pb_color, 'scale': pb_scale, 'tweak': pb_tweak, 'addOffsetGroups': pb_addOffsetGroups, 'addGroups': pb_addGroups, 'N': pb_N, 'R': pb_R, 'T': pb_T, 'X': pb_default, 'plusX': pb_plusX, 'minusX': pb_minusX, 'plusY': pb_plusY, 'minusY': pb_minusY, 'plusZ': pb_plusZ, 'minusZ': pb_minusZ, 'scaleDown': pb_scaleDown, 'scaleUp': pb_scaleUp }, 'layouts': { 'addCurve': gLayout_addCurve, 'color': gLayout_color }, 'widgets': { 'addCurve': widget_addCurve, 'copy': widget_copy, 'remove': widget_remove, 'color': widget_color, 'scale': widget_scale, 'tweak': widget_tweak, 'addGroups': widget_addGroups }, 'checkbox': { 'shapeOnly': cb_shapeOnly, 'viewport': cb_viewport, 'outliner': cb_outliner, 'nonUniform': cb_nonUniform, 'x': cb_x, 'y': cb_y, 'z': cb_z, 'zero': cb_zero, 'sdk': cb_sdk, 'offset': cb_offset, 'parent': cb_parent }, 'lineedit': { 'x': le_x, 'y': le_y, 'z': le_z, 'minScale': le_minScale, 'maxScale': le_maxScale }, 'slider': { 'scale': hSlider_scaleFactor }, 'label': { 'slider': label_sliderValue } }
def initialize(self): # add validators self.data['lineedit']['x'].setValidator( QtGui.QDoubleValidator(0, 180, 2)) self.data['lineedit']['y'].setValidator( QtGui.QDoubleValidator(0, 180, 2)) self.data['lineedit']['z'].setValidator( QtGui.QDoubleValidator(0, 180, 2)) self.data['lineedit']['minScale'].setValidator( QtGui.QDoubleValidator(1.0, 100, 2)) self.data['lineedit']['maxScale'].setValidator( QtGui.QDoubleValidator(1.0, 100, 2)) # add buttons - add control curve dirs = os.listdir(ctrls.CONTROLS_DIRECTORY) col = 6 row = 0 count = 0 self.mapperAddCurve = QtCore.QSignalMapper() for fileName in dirs: if fileName.endswith('.json'): if count == 6: count = 0 row += 1 btn = QtWidgets.QPushButton() btn.setToolTip(fileName) iconName = fileName.replace('.json', '.png') if iconName in dirs: iconPath = os.path.join(ctrls.CONTROLS_DIRECTORY, iconName) btn.setIcon(QtGui.QIcon(iconPath)) btn.setIconSize(QtCore.QSize(30, 30)) self.data['layouts']['addCurve'].addWidget(btn, row, count) count += 1 self.mapperAddCurve.setMapping(btn, fileName) btn.clicked.connect(self.mapperAddCurve.map) self.mapperAddCurve.mapped['QString'].connect(self.addCtrlShape) # add buttons - color self.mapperColor = QtCore.QSignalMapper() col = 8 row = 0 count = 4 for i in xrange(1, 32): if count == col: count = 0 row += 1 rgb = cmds.colorIndex(i, q=True) r, g, b = rgb[0], rgb[1], rgb[2] btn = QtWidgets.QPushButton() btn.btnIndex = count btn.setAutoFillBackground(True) values = "{r}, {g}, {b}, {a}".format(r=r * 255, g=g * 255, b=b * 255, a=255) btn.setStyleSheet("QPushButton { background-color: rgba(" + values + "); }") self.data['layouts']['color'].addWidget(btn, row, count) count += 1 self.mapperColor.setMapping(btn, i) btn.clicked.connect(self.mapperColor.map) self.mapperColor.mapped['int'].connect(self.colorShapes)
def expandCollapseRect(self): return QtCore.QRect(0, 0, self.width(), 20)
def dragDropRect(self): return QtCore.QRect(25, 7, 10, 6)
class AccordionWidget(QtWidgets.QScrollArea): itemCollapsed = QtCore.Signal(AccordionItem) itemMenuRequested = QtCore.Signal(AccordionItem) itemDragFailed = QtCore.Signal(AccordionItem) itemsReordered = QtCore.Signal() Boxed = 1 Rounded = 2 Square = 3 Maya = 4 NoDragDrop = 0 InternalMove = 1 def __init__(self, parent): QtWidgets.QScrollArea.__init__(self, parent) self.setFrameShape(QtWidgets.QScrollArea.NoFrame) self.setAutoFillBackground(False) self.setWidgetResizable(True) self.setMouseTracking(True) # self.verticalScrollBar().setMaximumWidth(10) widget = QtWidgets.QWidget(self) # define custom properties self._rolloutStyle = AccordionWidget.Rounded self._dragDropMode = AccordionWidget.NoDragDrop self._scrolling = False self._scrollInitY = 0 self._scrollInitVal = 0 self._itemClass = AccordionItem layout = QtWidgets.QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addStretch(1) widget.setLayout(layout) self.setWidget(widget) def setSpacing(self, spaceInt): self.widget().layout().setSpacing(spaceInt) def addItem(self, title, widget, collapsed=False): self.setUpdatesEnabled(False) item = self._itemClass(self, title, widget) item.setRolloutStyle(self.rolloutStyle()) item.setDragDropMode(self.dragDropMode()) layout = self.widget().layout() layout.insertWidget(layout.count() - 1, item) layout.setStretchFactor(item, 0) if collapsed: item.setCollapsed(collapsed) self.setUpdatesEnabled(True) return item def clear(self): self.setUpdatesEnabled(False) layout = self.widget().layout() while layout.count() > 1: item = layout.itemAt(0) # remove the item from the layout widget = item.widget() layout.removeItem(item) # close the widget and delete it widget.close() widget.deleteLater() self.setUpdatesEnabled(True) def eventFilter(self, object, event): if event.type() == QtCore.QEvent.MouseButtonPress: self.mousePressEvent(event) return True elif event.type() == QtCore.QEvent.MouseMove: self.mouseMoveEvent(event) return True elif event.type() == QtCore.QEvent.MouseButtonRelease: self.mouseReleaseEvent(event) return True return False def canScroll(self): return self.verticalScrollBar().maximum() > 0 def count(self): return self.widget().layout().count() - 1 def dragDropMode(self): return self._dragDropMode def indexOf(self, widget): """ \remarks Searches for widget(not including child layouts). Returns the index of widget, or -1 if widget is not found \return <int> """ layout = self.widget().layout() for index in range(layout.count()): if layout.itemAt(index).widget().widget() == widget: return index return -1 def isBoxedMode(self): return self._rolloutStyle == AccordionWidget.Boxed def itemClass(self): return self._itemClass def itemAt(self, index): layout = self.widget().layout() layout_count = layout.count() - 1 if index <= 0 and index < layout_count: return layout.itemAt(index).widget() return None def emitItemCollapsed(self, item): if not self.signalsBlocked(): self.itemCollapsed.emit(item) def emitItemDragFailed(self, item): if not self.signalsBlocked(): self.itemDragFailed.emit(item) def emitItemMenuRequested(self, item): if not self.signalsBlocked(): self.itemMenuRequested.emit(item) def emitItemsReordered(self): if not self.signalsBlocked(): self.itemsReordered.emit() def enterEvent(self, event): if self.canScroll(): QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.OpenHandCursor) def leaveEvent(self, event): if self.canScroll(): QtWidgets.QApplication.restoreOverrideCursor() def mouseMoveEvent(self, event): if self._scrolling: sbar = self.verticalScrollBar() smax = sbar.maximum() # calculate the distance moved for the moust point dy = event.globalY() - self._scrollInitY # calculate the percentage that is of the scroll bar dval = smax * (dy / float(sbar.height())) # calculate the new value sbar.setValue(self._scrollInitVal - dval) event.accept() def mousePressEvent(self, event): # handle a scroll event if event.button() == QtCore.Qt.LeftButton and self.canScroll(): self._scrolling = True self._scrollInitY = event.globalY() self._scrollInitVal = self.verticalScrollBar().value() QtWidgets.QApplication.setOverrideCursor( QtCore.Qt.ClosedHandCursor) event.accept() def mouseReleaseEvent(self, event): if self._scrolling: QtWidgets.QApplication.restoreOverrideCursor() self._scrolling = False self._scrollInitY = 0 self._scrollInitVal = 0 event.accept() def moveItemDown(self, index): layout = self.widget().layout() if (layout.count() - 1) > (index + 1): widget = layout.takeAt(index).widget() layout.insertWidget(index + 1, widget) def moveItemUp(self, index): if index > 0: layout = self.widget().layout() widget = layout.takeAt(index).widget() layout.insertWidget(index - 1, widget) def setBoxedMode(self, state): if state: self._rolloutStyle = AccordionWidget.Boxed else: self._rolloutStyle = AccordionWidget.Rounded def setDragDropMode(self, dragDropMode): self._dragDropMode = dragDropMode for item in self.findChildren(AccordionItem): item.setDragDropMode(self._dragDropMode) def setItemClass(self, itemClass): self._itemClass = itemClass def setRolloutStyle(self, rolloutStyle): self._rolloutStyle = rolloutStyle for item in self.findChildren(AccordionItem): item.setRolloutStyle(self._rolloutStyle) def rolloutStyle(self): return self._rolloutStyle def takeAt(self, index): self.setUpdatesEnabled(False) layout = self.widget().layout() layout_count = layout.count() - 1 if index <= 0 and index < layout_count: item = layout.itemAt(index) widget = item.widget() layout.removeItem(item) widget.close() self.setUpdatesEnabled(True) return widget def widgetAt(self, index): item = self.itemAt(index) if item: return item.widget() return None pyBoxedMode = QtCore.Property('bool', isBoxedMode, setBoxedMode)
def showMenu(self): if QtCore.QRect(0, 0, self.width(), 20).contains(self.mapFromGlobal(QtGui.QCursor.pos())): self._accordianWidget.emitItemMenuRequested(self)
def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(painter.Antialiasing) font = painter.font() font.setBold(True) painter.setFont(font) x = self.rect().x() y = self.rect().y() w = self.rect().width() - 1 h = self.rect().height() - 1 r = 8 # draw a rounded style if self._rolloutStyle == 2: # draw the text painter.drawText(x + 33, y + 3, w, 16, QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop, self.title()) # draw the triangle self.__drawTriangle(painter, x, y) # draw the borders pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Light)) pen.setWidthF(0.6) painter.setPen(pen) painter.drawRoundedRect(x + 1, y + 1, w - 1, h - 1, r, r) pen.setColor(self.palette().color(QtGui.QPalette.Shadow)) painter.setPen(pen) painter.drawRoundedRect(x, y, w - 1, h - 1, r, r) # draw a square style if self._rolloutStyle == 3: # draw the text painter.drawText(x + 33, y + 3, w, 16, QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop, self.title()) self.__drawTriangle(painter, x, y) # draw the borders pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Light)) pen.setWidthF(0.6) painter.setPen(pen) painter.drawRect(x + 1, y + 1, w - 1, h - 1) pen.setColor(self.palette().color(QtGui.QPalette.Shadow)) painter.setPen(pen) painter.drawRect(x, y, w - 1, h - 1) # draw a Maya style if self._rolloutStyle == 4: # draw the text painter.drawText(x + 33, y + 3, w, 16, QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop, self.title()) painter.setRenderHint(QtGui.QPainter.Antialiasing, False) self.__drawTriangle(painter, x, y) # draw the borders - top headerHeight = 20 headerRect = QtCore.QRect(x + 1, y + 1, w - 1, headerHeight) headerRectShadow = QtCore.QRect(x - 1, y - 1, w + 1, headerHeight + 2) # Highlight pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Light)) pen.setWidthF(0.4) painter.setPen(pen) painter.drawRect(headerRect) painter.fillRect(headerRect, QtGui.QColor(255, 255, 255, 18)) # Shadow pen.setColor(self.palette().color(QtGui.QPalette.Dark)) painter.setPen(pen) painter.drawRect(headerRectShadow) if not self.isCollapsed(): # draw the lover border pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Dark)) pen.setWidthF(0.8) painter.setPen(pen) offSet = headerHeight + 3 bodyRect = QtCore.QRect(x, y + offSet, w, h - offSet) bodyRectShadow = QtCore.QRect(x + 1, y + offSet, w + 1, h - offSet + 1) painter.drawRect(bodyRect) pen.setColor(self.palette().color(QtGui.QPalette.Light)) pen.setWidthF(0.4) painter.setPen(pen) painter.drawRect(bodyRectShadow) # draw a boxed style elif self._rolloutStyle == 1: if self.isCollapsed(): arect = QtCore.QRect(x + 1, y + 9, w - 1, 4) brect = QtCore.QRect(x, y + 8, w - 1, 4) text = '+' else: arect = QtCore.QRect(x + 1, y + 9, w - 1, h - 9) brect = QtCore.QRect(x, y + 8, w - 1, h - 9) text = '-' # draw the borders pen = QtGui.QPen(self.palette().color(QtGui.QPalette.Light)) pen.setWidthF(0.6) painter.setPen(pen) painter.drawRect(arect) pen.setColor(self.palette().color(QtGui.QPalette.Shadow)) painter.setPen(pen) painter.drawRect(brect) painter.setRenderHint(painter.Antialiasing, False) painter.setBrush(self.palette().color( QtGui.QPalette.Window).darker(120)) painter.drawRect(x + 10, y + 1, w - 20, 16) painter.drawText(x + 16, y + 1, w - 32, 16, QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter, text) painter.drawText(x + 10, y + 1, w - 20, 16, QtCore.Qt.AlignCenter, self.title()) if self.dragDropMode(): rect = self.dragDropRect() # draw the lines l = rect.left() r = rect.right() cy = rect.center().y() for y in (cy - 3, cy, cy + 3): painter.drawLine(l, y, r, y) painter.end()
def importSkinWeight(importPath, meshes, namespace=False): """ Import skinWeight from a json file, to a list of meshes. To a whole mesh, or selected vertices. Args: filepath: The file path where a json file is loaded. meshes: A list of mesh nodes. If [], import all available meshes. namespace: True to respect imported namespace data. False to ignore any namespaces. Returns: True if import succeeds. False if import fails. """ with open(importPath) as infile: try: data = json.load(infile) LOG.info('Loaded skinWeight data from {0}.'.format(importPath)) except: LOG.error('Unable to load skinWeight data from {0}.'.format(importPath)) return False if not meshes: meshes = data.keys() for mesh in meshes: selectedIndice = [] selectedVerts = [v.split('.vtx')[-1] for v in cmds.ls(sl=1, fl=1) if (('.vtx' in v) and (mesh in v))] for v in selectedVerts: id = re.findall('\\d+', v)[0] selectedIndice.append(id) if namespace: if not (mesh in data): LOG.warning('Unable to find mesh data for "{0}"'.format(mesh)) continue meshName = mesh else: shortName = mesh.split(':')[-1] meshName = '' for m in data.keys(): if m.split(':')[-1] == shortName: meshName = m if not meshName: LOG.warning('Unable to find mesh data for "{0}"'.format(shortName)) continue # if mesh is not in current scene, skip if not cmds.objExists(meshName): continue weights = data[meshName]['weights'] infs = data[meshName]['infs'] skinClusterName = data[meshName]['skinCluster'] skinNorm = data[meshName]['nw'] if cmds.polyEvaluate(mesh, v=1) != len(weights.keys()): LOG.warning('Mesh "{0}": Vertex number does not match with the imported skinCluster "{1}"'.format( mesh, skinClusterName)) # progressBar visualization total = len(weights.items()) progressBar = QtWidgets.QProgressBar() progressBar.setMinimumSize(QtCore.QSize(450, 40)) progressBar.setMinimum(1) progressBar.setMaximum(total) progressBar.setWindowTitle('Importing skincluster: {}'.format(mesh)) progressBar.show() completed = 0 # vertices selection if selectedIndice: # get skinCluster currentName = getSkinCluster(mesh) # check if skinCluster exists if not currentName: LOG.error('Mesh "{0}": SkinCluster missing selected vertices'.format(mesh)) return False # check the name of skinCluster elif currentName != skinClusterName: LOG.warning('SkinCluster "{0}": Name does not match with the imported skinCluster "{1}"'.format(currentName, skinClusterName)) # check the number of influences currentInfs = cmds.skinCluster(currentName, q=1, inf=1) if len(currentInfs) != len(infs): LOG.warning('SkinCluster "{0}": Influence number does not match with the imported skinCluster "{1}"'.format(currentName, skinClusterName)) # unlock influences used by skincluster for inf in infs: if not cmds.objExists(inf): LOG.warning('Unable to find influence "{0}"]'.format(inf)) continue cmds.setAttr('%s.liw' % inf, 0) for vertId in selectedIndice: if not (vertId in weights): LOG.info('Unable to find weight data for {0}.vtx[{1}]'.format(mesh, vertId)) continue # TODO # deal with vertices with missing weight data: missing data for vertId # currently acting awkward weightData = weights[vertId] wlAttr = '%s.weightList[%s]' % (currentName, vertId) completed += 1 progressBar.setValue(completed) for infId, infValue in weightData.items(): wAttr = '.weights[%s]' % infId cmds.setAttr(wlAttr + wAttr, infValue) return True # get skinCluster if getSkinCluster(mesh): cmds.delete(getSkinCluster(mesh)) create(mesh, infs, name=skinClusterName, nw=skinNorm) # normalize needs turned off for the prune to work if skinNorm != 0: cmds.setAttr('%s.normalizeWeights' % skinClusterName, 0) cmds.skinPercent(skinClusterName, mesh, nrm=False, prw=100) # restore normalize setting cmds.setAttr('%s.normalizeWeights' % skinClusterName, skinNorm) # apply weights for vertId, weightData in weights.items(): wlAttr = '%s.weightList[%s]' % (skinClusterName, vertId) completed += 1 progressBar.setValue(completed) for infId, infValue in weightData.items(): wAttr = '.weights[%s]' % infId cmds.setAttr(wlAttr + wAttr, infValue) return True
def exportSkinWeight(exportPath, meshes, namespace=False): """ Export skinWeights of a list of meshes to a json file. Args: exportPath: The file path where a json file is saved. meshes: A list of mesh nodes. namespace: True to export with namespace. False to export without namespace. Returns: True if export succeeds. False if export fails. """ data = {} if not meshes: LOG.error('Meshes input {0} is not valid.'.format(meshes)) return False for mesh in meshes: skinCluster = getSkinCluster(mesh) if not skinCluster: LOG.warning('Mesh {} has no skinCluster, skipping... '.format(mesh)) continue skinNorm = cmds.getAttr('%s.normalizeWeights' % skinCluster) # get the MFnSkinCluster for clusterName selList = om.MSelectionList() selList.add(skinCluster) clusterNode = om.MObject() selList.getDependNode(0, clusterNode) skinFn = oma.MFnSkinCluster(clusterNode) # get the MDagPath for all influence infDags = om.MDagPathArray() skinFn.influenceObjects(infDags) # { # "mesh_name": { # "weights": { # "vert id": { # "influence id": weight, # "influence id": weight # } # }, # "infs": [inf1, inf2, inf3, inf4, ...], # "skinCluster": skinCluster_name # } # } infIds = {} infs = [] unique = True for i in xrange(infDags.length()): infPath = infDags[i].partialPathName() if '|' in infPath: LOG.warning('Influence of {}: "{}" is not have a unique name.'.format(mesh, infDags[i].fullPathName())) unique = False infId = int(skinFn.indexForInfluenceObject(infDags[i])) infIds[infId] = i infs.append(infPath) if not unique: LOG.warning('{} skincluster export is skipped. Please make sure all influence names are unique'.format(mesh)) continue # get the MPlug for the weightList and weights attributes wlPlug = skinFn.findPlug('weightList') wPlug = skinFn.findPlug('weights') wlAttr = wlPlug.attribute() wAttr = wPlug.attribute() wInfIds = om.MIntArray() # progressBar visualization total = wlPlug.numElements() progressBar = QtWidgets.QProgressBar() progressBar.setMinimumSize(QtCore.QSize(450, 40)) progressBar.setMinimum(1) progressBar.setMaximum(total) progressBar.setWindowTitle('Exporting skincluster: {}'.format(mesh)) progressBar.show() completed = 0 weights = {} for vId in xrange(wlPlug.numElements()): vWeights = {} # tell the weights attribute which vertex id it represents wPlug.selectAncestorLogicalIndex(vId, wlAttr) # get the indice of all non-zero weights for this vert wPlug.getExistingArrayAttributeIndices(wInfIds) # create a copy of the current wPlug infPlug = om.MPlug(wPlug) completed += 1 progressBar.setValue(completed) for infId in wInfIds: # tell the infPlug it represents the current influence id infPlug.selectAncestorLogicalIndex(infId, wAttr) # add this influence and its weight to this verts weights try: vWeights[infIds[infId]] = infPlug.asDouble() except KeyError: # assumes a removed influence pass weights[vId] = vWeights if namespace: meshName = mesh else: meshName = mesh.split(':')[-1] data[meshName] = {'weights': weights, 'infs': infs, 'skinCluster': skinCluster, 'nw': skinNorm} with open(exportPath, 'w') as outfile: try: if data: json.dump(data, outfile, sort_keys=True, indent=4) LOG.info('Exported skin weights for mesh {0}.'.format(meshes)) return True else: LOG.info('No valid skinCluster is found for mesh {0}.'.format(meshes)) return False except: LOG.error('Unable to export skinWeight data to {0}.'.format(exportPath)) return False
def setupUi(self): self.setObjectName("jointFactory") mainLayout= QtWidgets.QVBoxLayout(self) # buttons pb_toggle = QtWidgets.QPushButton("Toggle Local Axes Visibility") pb_orientJoints = QtWidgets.QPushButton("Orient Joints") pb_planarOrientJoints = QtWidgets.QPushButton("Planar Orient Joints for 3") pb_minusX = QtWidgets.QPushButton("-") pb_plusX = QtWidgets.QPushButton("+") pb_minusY = QtWidgets.QPushButton("-") pb_plusY = QtWidgets.QPushButton("+") pb_minusZ = QtWidgets.QPushButton("-") pb_plusZ = QtWidgets.QPushButton("+") pb_insertJoints = QtWidgets.QPushButton("Apply") pb_copyJointOrient = QtWidgets.QPushButton("Copy Joint Orientation") pb_turnOffLRA = QtWidgets.QPushButton("Turn Off All LRA") pb_minusX.setMaximumSize(QtCore.QSize(30, 16777215)) pb_plusX.setMaximumSize(QtCore.QSize(30, 16777215)) pb_minusY.setMaximumSize(QtCore.QSize(30, 16777215)) pb_plusY.setMaximumSize(QtCore.QSize(30, 16777215)) pb_minusZ.setMaximumSize(QtCore.QSize(30, 16777215)) pb_plusZ.setMaximumSize(QtCore.QSize(30, 16777215)) # radio buttons rb_worldUpAxisX = QtWidgets.QRadioButton("x") rb_worldUpAxisY = QtWidgets.QRadioButton("y") rb_worldUpAxisZ = QtWidgets.QRadioButton("z") rb_aimAxisX = QtWidgets.QRadioButton("x") rb_aimAxisY = QtWidgets.QRadioButton("y") rb_aimAxisZ = QtWidgets.QRadioButton("z") rb_upAxisX = QtWidgets.QRadioButton("x") rb_upAxisY = QtWidgets.QRadioButton("y") rb_upAxisZ = QtWidgets.QRadioButton("z") rbg_worldUpAxis = QtWidgets.QButtonGroup(self) rbg_worldUpAxis.addButton(rb_worldUpAxisX) rbg_worldUpAxis.addButton(rb_worldUpAxisY) rbg_worldUpAxis.addButton(rb_worldUpAxisZ) rbg_aimAxis = QtWidgets.QButtonGroup(self) rbg_aimAxis.addButton(rb_aimAxisX) rbg_aimAxis.addButton(rb_aimAxisY) rbg_aimAxis.addButton(rb_aimAxisZ) rbg_upAxis = QtWidgets.QButtonGroup(self) rbg_upAxis.addButton(rb_upAxisX) rbg_upAxis.addButton(rb_upAxisY) rbg_upAxis.addButton(rb_upAxisZ) hLayout_worldUpAxis = QtWidgets.QHBoxLayout() hLayout_worldUpAxis.addWidget(rb_worldUpAxisX) hLayout_worldUpAxis.addWidget(rb_worldUpAxisY) hLayout_worldUpAxis.addWidget(rb_worldUpAxisZ) hLayout_aimAxis = QtWidgets.QHBoxLayout() hLayout_aimAxis.addWidget(rb_aimAxisX) hLayout_aimAxis.addWidget(rb_aimAxisY) hLayout_aimAxis.addWidget(rb_aimAxisZ) hLayout_upAxis = QtWidgets.QHBoxLayout() hLayout_upAxis.addWidget(rb_upAxisX) hLayout_upAxis.addWidget(rb_upAxisY) hLayout_upAxis.addWidget(rb_upAxisZ) # checkbox cb_orientChildren = QtWidgets.QCheckBox("Orient children") cb_orient2World = QtWidgets.QCheckBox("Orient Joint to World") cb_orientChildren.setLayoutDirection(QtCore.Qt.LeftToRight) cb_orient2World.setLayoutDirection(QtCore.Qt.LeftToRight) # combo box combo_upAxis = QtWidgets.QComboBox() combo_upAxis.addItem("+") combo_upAxis.addItem("-") combo_aimAxis = QtWidgets.QComboBox() combo_aimAxis.addItem("+") combo_aimAxis.addItem("-") combo_worldUpAxis = QtWidgets.QComboBox() combo_worldUpAxis.addItem("+") combo_worldUpAxis.addItem("-") # labels label_upAxis = QtWidgets.QLabel("Up Axis") label_worldUpAxis = QtWidgets.QLabel("World Up Axis:") label_aimAxis = QtWidgets.QLabel("Aim Axis:") label_x = QtWidgets.QLabel("x") label_y = QtWidgets.QLabel("y") label_z = QtWidgets.QLabel("z") label_insertJoints = QtWidgets.QLabel("Insert Joints:") label_upAxis.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) label_worldUpAxis.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) label_aimAxis.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) # line edits le_x = QtWidgets.QLineEdit() le_y = QtWidgets.QLineEdit() le_z = QtWidgets.QLineEdit() le_insertJoints = QtWidgets.QLineEdit() spacerStart = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerEnd = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) gLayout_orient = QtWidgets.QGridLayout() gLayout_orient.setContentsMargins(-1, -1, 0, -1) gLayout_orient.addLayout(hLayout_worldUpAxis, 4, 2, 1, 1) gLayout_orient.addLayout(hLayout_aimAxis, 2, 2, 1, 1) gLayout_orient.addWidget(cb_orientChildren, 0, 2, 1, 1) gLayout_orient.addWidget(combo_upAxis, 3, 3, 1, 1) gLayout_orient.addItem(spacerStart, 2, 0, 1, 1) gLayout_orient.addItem(spacerEnd, 2, 4, 1, 1) gLayout_orient.addWidget(cb_orient2World, 1, 2, 1, 1) gLayout_orient.addWidget(label_upAxis, 3, 1, 1, 1) gLayout_orient.addWidget(combo_worldUpAxis, 4, 3, 1, 1) gLayout_orient.addWidget(combo_aimAxis, 2, 3, 1, 1) gLayout_orient.addWidget(label_worldUpAxis, 4, 1, 1, 1) gLayout_orient.addWidget(label_aimAxis, 2, 1, 1, 1) gLayout_orient.addLayout(hLayout_upAxis, 3, 2, 1, 1) spacerEnd = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerStart = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) gLayout_tweak = QtWidgets.QGridLayout() gLayout_tweak.addWidget(label_x, 0, 1, 1, 1) gLayout_tweak.addWidget(le_z, 2, 2, 1, 1) gLayout_tweak.addWidget(le_y, 1, 2, 1, 1) gLayout_tweak.addWidget(label_y, 1, 1, 1, 1) gLayout_tweak.addWidget(le_x, 0, 2, 1, 1) gLayout_tweak.addWidget(label_z, 2, 1, 1, 1) gLayout_tweak.addItem(spacerEnd, 0, 6, 1, 1) gLayout_tweak.addItem(spacerStart, 0, 0, 1, 1) gLayout_tweak.addWidget(pb_minusX, 0, 3, 1, 1) gLayout_tweak.addWidget(pb_plusX, 0, 4, 1, 1) gLayout_tweak.addWidget(pb_minusY, 1, 3, 1, 1) gLayout_tweak.addWidget(pb_plusY, 1, 4, 1, 1) gLayout_tweak.addWidget(pb_minusZ, 2, 3, 1, 1) gLayout_tweak.addWidget(pb_plusZ, 2, 4, 1, 1) line_1 = QtWidgets.QFrame() line_1.setFrameShape(QtWidgets.QFrame.HLine) line_1.setFrameShadow(QtWidgets.QFrame.Sunken) line_2 = QtWidgets.QFrame() line_2.setFrameShape(QtWidgets.QFrame.HLine) line_2.setFrameShadow(QtWidgets.QFrame.Sunken) spacerStart = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerEnd = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) hLayout_insert = QtWidgets.QHBoxLayout() hLayout_insert.setContentsMargins(0, -1, 0, -1) hLayout_insert.addItem(spacerStart) hLayout_insert.addWidget(label_insertJoints) hLayout_insert.addWidget(le_insertJoints) hLayout_insert.addWidget(pb_insertJoints) hLayout_insert.addItem(spacerEnd) mainLayout.addWidget(pb_toggle) mainLayout.addLayout(gLayout_orient) mainLayout.addWidget(pb_orientJoints) mainLayout.addWidget(pb_planarOrientJoints) mainLayout.addWidget(line_1) mainLayout.addLayout(gLayout_tweak) mainLayout.addWidget(line_2) mainLayout.addLayout(hLayout_insert) mainLayout.addWidget(pb_copyJointOrient) mainLayout.addWidget(pb_turnOffLRA) mainLayout.setStretch(0, 1) self.data = { 'buttons': { 'toggle': pb_toggle, 'orientJoints': pb_orientJoints, 'planarOrientJoints': pb_planarOrientJoints, 'minusX': pb_minusX, 'plusX': pb_plusX, 'minusY': pb_minusY, 'plusY': pb_plusY, 'minusZ': pb_minusZ, 'plusZ': pb_plusZ, 'insertJoints': pb_insertJoints, 'copyJointOrient': pb_copyJointOrient, 'turnOffLRA': pb_turnOffLRA }, 'radio': { 'worldUpAxisX': rb_worldUpAxisX, 'worldUpAxisY': rb_worldUpAxisY, 'worldUpAxisZ': rb_worldUpAxisZ, 'aimAxisX': rb_aimAxisX, 'aimAxisY': rb_aimAxisY, 'aimAxisZ': rb_aimAxisZ, 'upAxisX': rb_upAxisX, 'upAxisY': rb_upAxisY, 'upAxisZ': rb_upAxisZ }, 'rbg': { 'worldUpAxis': rbg_worldUpAxis, 'aimAxis': rbg_aimAxis, 'upAxis': rbg_upAxis }, 'checkbox': { 'orientChildren': cb_orientChildren, 'orient2World': cb_orient2World }, 'combo': { 'upAxis': combo_upAxis, 'aimAxis': combo_aimAxis, 'worldUpAxis': combo_worldUpAxis }, 'lineedit': { 'x': le_x, 'y': le_y, 'z': le_z, 'insertJoints': le_insertJoints } }