def setupTabWidget(self): from SliderContainers.DensityLayout import DensityLayout from SliderContainers.VelocityLayout import VelocityLayout from SliderContainers.TurbulenceLayout import TurbulenceLayout from SliderContainers.TemperatureLayout import TemperatureLayout from SliderContainers.FuelLayout import FuelLayout from SliderContainers.ColorLayout import ColorLayout from SliderContainers.DynamicSimulationLayout import DynamicSimulationLayout # -------------------------------------------------------------------------------------------------------------- DensityBox = QtGui.QGroupBox() self.DensityLayout = DensityLayout() self.DensityLayout.setFluidBoxName(self.fluidBoxName) DensityBox.setLayout(self.DensityLayout.getLayout()) VelocityBox = QtGui.QGroupBox() self.VelocityLayout = VelocityLayout() self.VelocityLayout.setFluidBoxName(self.fluidBoxName) VelocityBox.setLayout(self.VelocityLayout.getLayout()) TurbulenceBox = QtGui.QGroupBox() self.TurbulenceLayout = TurbulenceLayout() self.TurbulenceLayout.setFluidBoxName(self.fluidBoxName) TurbulenceBox.setLayout(self.TurbulenceLayout.getLayout()) TemperatureBox = QtGui.QGroupBox() self.TemperatureLayout = TemperatureLayout() self.TemperatureLayout.setFluidBoxName(self.fluidBoxName) TemperatureBox.setLayout(self.TemperatureLayout.getLayout()) FuelBox = QtGui.QGroupBox() self.FuelLayout = FuelLayout() self.FuelLayout.setFluidBoxName(self.fluidBoxName) FuelBox.setLayout(self.FuelLayout.getLayout()) ColorBox = QtGui.QGroupBox() self.ColorLayout = ColorLayout() self.ColorLayout.setFluidBoxName(self.fluidBoxName) ColorBox.setLayout(self.ColorLayout.getLayout()) DynamicSimulationBox = QtGui.QGroupBox() self.DynamicSimulationLayout = DynamicSimulationLayout() self.DynamicSimulationLayout.setFluidBoxName(self.fluidBoxName) DynamicSimulationBox.setLayout(self.DynamicSimulationLayout.getLayout()) # -------------------------------------------------------------------------------------------------------------- # The toolbox stores all slider containers self.toolBox = QtGui.QToolBox() self.toolBox.addItem(DynamicSimulationBox, "Dynamic Simulation") self.toolBox.addItem(DensityBox, "Density") self.toolBox.addItem(VelocityBox, "Velocity") self.toolBox.addItem(TurbulenceBox, "Turbulence") self.toolBox.addItem(TemperatureBox, "Temperature") self.toolBox.addItem(FuelBox, "Fuel") self.toolBox.addItem(ColorBox, "Color") # Disable tool box items if method is set to 0 in maya self.toolBox.setItemEnabled(1, self.isItemEbabled(self.fluidBoxName + '.' + 'densityMethod')) self.toolBox.setItemEnabled(2, self.isItemEbabled(self.fluidBoxName + '.' + 'velocityMethod')) self.toolBox.setItemEnabled(4, self.isItemEbabled(self.fluidBoxName + '.' + 'temperatureMethod')) self.toolBox.setItemEnabled(5, self.isItemEbabled(self.fluidBoxName + '.' + 'fuelMethod')) self.toolBox.setItemEnabled(6, self.isItemEbabled(self.fluidBoxName + '.' + 'colorMethod')) self.initialToolBoxComponents() self.toolBox.currentChanged.connect(self.toolBoxChanged_Event) vBoxlayout = QtGui.QVBoxLayout() vBoxlayout.addWidget(self.toolBox) self.parameterTab = QtGui.QWidget() self.parameterTab.setLayout(vBoxlayout)
class ParameterTab(object): def __init__(self, boxName): # Logging self.lgr = logging.getLogger('FluidExplorerPlugin') self.fluidBoxName = boxName self.setupTabWidget() def initialToolBoxComponents(self): for itemIndex in range(0, self.toolBox.count()): self.toolBox.setItemIcon(itemIndex, QtGui.QIcon(':/arrow_small_1.png')) self.toolBox.setItemIcon(0, QtGui.QIcon(':/arrow_small_2.png')) def setupTabWidget(self): from SliderContainers.DensityLayout import DensityLayout from SliderContainers.VelocityLayout import VelocityLayout from SliderContainers.TurbulenceLayout import TurbulenceLayout from SliderContainers.TemperatureLayout import TemperatureLayout from SliderContainers.FuelLayout import FuelLayout from SliderContainers.ColorLayout import ColorLayout from SliderContainers.DynamicSimulationLayout import DynamicSimulationLayout # -------------------------------------------------------------------------------------------------------------- DensityBox = QtGui.QGroupBox() self.DensityLayout = DensityLayout() self.DensityLayout.setFluidBoxName(self.fluidBoxName) DensityBox.setLayout(self.DensityLayout.getLayout()) VelocityBox = QtGui.QGroupBox() self.VelocityLayout = VelocityLayout() self.VelocityLayout.setFluidBoxName(self.fluidBoxName) VelocityBox.setLayout(self.VelocityLayout.getLayout()) TurbulenceBox = QtGui.QGroupBox() self.TurbulenceLayout = TurbulenceLayout() self.TurbulenceLayout.setFluidBoxName(self.fluidBoxName) TurbulenceBox.setLayout(self.TurbulenceLayout.getLayout()) TemperatureBox = QtGui.QGroupBox() self.TemperatureLayout = TemperatureLayout() self.TemperatureLayout.setFluidBoxName(self.fluidBoxName) TemperatureBox.setLayout(self.TemperatureLayout.getLayout()) FuelBox = QtGui.QGroupBox() self.FuelLayout = FuelLayout() self.FuelLayout.setFluidBoxName(self.fluidBoxName) FuelBox.setLayout(self.FuelLayout.getLayout()) ColorBox = QtGui.QGroupBox() self.ColorLayout = ColorLayout() self.ColorLayout.setFluidBoxName(self.fluidBoxName) ColorBox.setLayout(self.ColorLayout.getLayout()) DynamicSimulationBox = QtGui.QGroupBox() self.DynamicSimulationLayout = DynamicSimulationLayout() self.DynamicSimulationLayout.setFluidBoxName(self.fluidBoxName) DynamicSimulationBox.setLayout(self.DynamicSimulationLayout.getLayout()) # -------------------------------------------------------------------------------------------------------------- # The toolbox stores all slider containers self.toolBox = QtGui.QToolBox() self.toolBox.addItem(DynamicSimulationBox, "Dynamic Simulation") self.toolBox.addItem(DensityBox, "Density") self.toolBox.addItem(VelocityBox, "Velocity") self.toolBox.addItem(TurbulenceBox, "Turbulence") self.toolBox.addItem(TemperatureBox, "Temperature") self.toolBox.addItem(FuelBox, "Fuel") self.toolBox.addItem(ColorBox, "Color") # Disable tool box items if method is set to 0 in maya self.toolBox.setItemEnabled(1, self.isItemEbabled(self.fluidBoxName + '.' + 'densityMethod')) self.toolBox.setItemEnabled(2, self.isItemEbabled(self.fluidBoxName + '.' + 'velocityMethod')) self.toolBox.setItemEnabled(4, self.isItemEbabled(self.fluidBoxName + '.' + 'temperatureMethod')) self.toolBox.setItemEnabled(5, self.isItemEbabled(self.fluidBoxName + '.' + 'fuelMethod')) self.toolBox.setItemEnabled(6, self.isItemEbabled(self.fluidBoxName + '.' + 'colorMethod')) self.initialToolBoxComponents() self.toolBox.currentChanged.connect(self.toolBoxChanged_Event) vBoxlayout = QtGui.QVBoxLayout() vBoxlayout.addWidget(self.toolBox) self.parameterTab = QtGui.QWidget() self.parameterTab.setLayout(vBoxlayout) def createConnections(self): pass def getSelectedValuesFromSlider(self): self.lgr.info('Read selected values from paramter tab') from Utils.RangeSliderSpan import SliderSpanSelected self.selectedSliderValues = SliderSpanSelected(self.DynamicSimulationLayout, self.DensityLayout, self.VelocityLayout, self.TurbulenceLayout, self.TemperatureLayout, self.FuelLayout, self.ColorLayout) return self.selectedSliderValues def randomValuesSnapshot(self): return self.VelocityLayout.containerSwirl.getSliderValues() def toolBoxChanged_Event(self): currentTabIndex = self.toolBox.currentIndex() for itemIndex in range(self.toolBox.count()): self.toolBox.setItemIcon(itemIndex, QtGui.QIcon(':/arrow_small_1.png')) if itemIndex == currentTabIndex: self.toolBox.setItemIcon(itemIndex, QtGui.QIcon(':/arrow_small_2.png')) self.initAllSlidersOfTheBox() def getTab(self): return self.parameterTab def initAllSlidersOfTheBox(self): pass def isItemEbabled(self, cmdStr): try: flag = cmds.getAttr(cmdStr) if flag == 0: return False else: return True except ValueError: return True