# maya/scripts/qt_dev/
# particles_tabs_ui.py
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2.QtCore import *
from PySide2.QtUiTools import *
from sliders import *
from gen_points1 import *
from gen_points_Ring import*
import maya.cmds as cmds
#===================================================================
# A generic base class from which specialized tab pages are derived.
class AbstractTabPage(QWidget):
def __init__(self, panelName):
QWidget.__init__(self, None)
self.name = panelName
vlayout = QVBoxLayout()
self.setLayout(vlayout)
self.addWidgetsPanel(vlayout)
vlayout.addStretch()
self.setFocusPolicy( Qt.StrongFocus )
#---------------------------------------------------------------
def addWidgetsPanel(self, parentLayout):
raise NotImplementedError("addWidgetsPanel() must be implemented")
#---------------------------------------------------------------
def doAction(self, parentLayout):
raise NotImplementedError("doAction must be implemented")
#---------------------------------------------------------------
def focusOutEvent(self, event):
# A derived class should implement this if they wish to
# respond when a page loses focus.
pass
#---------------------------------------------------------------
def focusInEvent(self, event):
# A derived class should implement this if they wish to
# respond when a page gains focus.
pass
#===================================================================
class BoxTabPage(AbstractTabPage):
def __init__(self, panelName):
AbstractTabPage.__init__(self, panelName)
# Note: the base class lays out the UI
#-------------------------------------------------------------
def addWidgetsPanel(self, parentLayout):
vlayout = QVBoxLayout()
self.numParticlesSlider = IntSlider('Num Particles', 1, 1000, 500, vlayout)
self.widthSlider = FloatSlider('Width', 0.1, 25, 5, vlayout)
self.heightSlider = FloatSlider('Height', 0.1, 25, 5, vlayout)
self.depthSlider = FloatSlider('Depth', 0.1, 25, 5, vlayout)
parentLayout.addLayout(vlayout)
#-------------------------------------------------------------
def doAction(self):
num = self.numParticlesSlider.getValue()
w = self.widthSlider.getValue()
h = self.heightSlider.getValue()
d = self.depthSlider.getValue()
data = box(num, w, h, d)
tnode = cmds.nParticle(p=data)[0]
return tnode
#cmds.nParticle(p=data)
#-------------------------------------------------------------
#===================================================================
class SphereTabPage(AbstractTabPage):
def __init__(self, panelName):
AbstractTabPage.__init__(self, panelName)
# Note: the base class lays out the UI
#-------------------------------------------------------------
def addWidgetsPanel(self, parentLayout):
vlayout = QVBoxLayout()
self.numParticlesSlider = IntSlider('Num Particles', 1, 1000, 500, vlayout)
self.radiusSlider = FloatSlider('Radius', 0.1, 25, 5, vlayout)
parentLayout.addLayout(vlayout)
#-------------------------------------------------------------
def doAction(self):
num = self.numParticlesSlider.getValue()
rad = self.radiusSlider.getValue()
data = spherical(num, rad)
tnode = cmds.nParticle(p=data)[0]
return tnode
#cmds.nParticle(p=data)
#-------------------------------------------------------------
#===================================================================
class ConeTabPage(AbstractTabPage):
def __init__(self, panelName):
AbstractTabPage.__init__(self, panelName)
# Note: the base class lays out the UI
#-------------------------------------------------------------
def addWidgetsPanel(self, parentLayout):
vlayout = QVBoxLayout()
self.numParticlesSlider = IntSlider('Num Particles', 1, 1000, 500, vlayout)
self.radiusSlider = FloatSlider('Radius', 0.1, 25, 5, vlayout)
self.heightSlider = FloatSlider('Height', 0.1, 25, 5, vlayout)
parentLayout.addLayout(vlayout)
#-------------------------------------------------------------
def doAction(self):
num = self.numParticlesSlider.getValue()
rad = self.radiusSlider.getValue()
height = self.heightSlider.getValue()
data = cone(num, rad, height)
tnode = cmds.nParticle(p=data)[0]
return tnode
#cmds.nParticle(p=data)
#-------------------------------------------------------------
#===================================================================
class DiskTabPage(AbstractTabPage):
def __init__(self, panelName):
AbstractTabPage.__init__(self, panelName)
# Note: the base class lays out the UI
#-------------------------------------------------------------
def addWidgetsPanel(self, parentLayout):
vlayout = QVBoxLayout()
self.numParticlesSlider = IntSlider('Num Particles', 1, 1000, 500, vlayout)
self.radiusSlider = FloatSlider('Radius', 0.1, 25, 5, vlayout)
parentLayout.addLayout(vlayout)
#-------------------------------------------------------------
def doAction(self):
num = self.numParticlesSlider.getValue()
rad = self.radiusSlider.getValue()
data = disk(num, rad)
tnode = cmds.nParticle(p=data)[0]
return tnode
#cmds.nParticle(p=data)
#-------------------------------------------------------------
#===================================================================
class CylinderTabPage(AbstractTabPage):
def __init__(self, panelName):
AbstractTabPage.__init__(self, panelName)
# Note: the base class lays out the UI
#-------------------------------------------------------------
def addWidgetsPanel(self, parentLayout):
vlayout = QVBoxLayout()
self.numParticlesSlider = IntSlider('Num Particles', 1, 1000, 500, vlayout)
self.radiusSlider = FloatSlider('Radius', 0.1, 25, 5, vlayout)
self.heightSlider = FloatSlider('Height', 0.1, 25, 5, vlayout)
parentLayout.addLayout(vlayout)
#-------------------------------------------------------------
def doAction(self):
num = self.numParticlesSlider.getValue()
rad = self.radiusSlider.getValue()
height = self.heightSlider.getValue()
data = cylinder(num, rad, height)
tnode = cmds.nParticle(p=data)[0]
return tnode
#cmds.nParticle(p=data)
#-------------------------------------------------------------
#===================================================================
class RingTabPage(AbstractTabPage):
def __init__(self, panelName):
AbstractTabPage.__init__(self, panelName)
# Note: the base class lays out the UI
#-------------------------------------------------------------
def addWidgetsPanel(self, parentLayout):
vlayout = QVBoxLayout()
self.numParticlesSlider = IntSlider('Num Particles', 1, 1000, 500, vlayout)
self.innerRSlider = FloatSlider('innerR', 0.1, 25, 5, vlayout)
self.outerRSlider = FloatSlider('outerR', 0.1, 25, 10, vlayout)
parentLayout.addLayout(vlayout)
#-------------------------------------------------------------
def doAction(self):
num = self.numParticlesSlider.getValue()
innerR = self.innerRSlider.getValue()
outerR = self.outerRSlider.getValue()
data = ring(num, innerR, outerR)
tnode = cmds.nParticle(p=data)[0]
return tnode
#cmds.nParticle(p=data)
#-------------------------------------------------------------
#===================================================================
class TorousTabPage(AbstractTabPage):
def __init__(self, panelName):
AbstractTabPage.__init__(self, panelName)
# Note: the base class lays out the UI
#-------------------------------------------------------------
def addWidgetsPanel(self, parentLayout):
vlayout = QVBoxLayout()
self.numParticlesSlider = IntSlider('Num Particles', 1, 1000, 500, vlayout)
self.maxRadiusSlider = FloatSlider('innerR', 0.1, 25, 10, vlayout)
self.minRadiusSlider = FloatSlider('outerR', 0.1, 25, 5, vlayout)
parentLayout.addLayout(vlayout)
#-------------------------------------------------------------
def doAction(self):
num = self.numParticlesSlider.getValue()
maxRadius = self.maxRadiusSlider.getValue()
minRadius = self.minRadiusSlider.getValue()
data = torous(num, maxRadius, minRadius)
tnode = cmds.nParticle(p=data)[0]
return tnode
#cmds.nParticle(p=data)
#-------------------------------------------------------------