예제 #1
0
 def create(self):
     values = None
     if self.material:
         # Material params have precedence over declarations in shader code
         params = self.material.shaderParameters
         values = params.get(self.uniform.name)
     if values is None:
         values = np.atleast_2d(self.uniform.values)
     else:
         values = np.atleast_2d(values)
     rows, cols = values.shape
     self.widgets = []
     for row in range(rows):
         widgets = []
         for col in range(cols):
             child = self.createWidget(values[row,col], row)
             self.addWidget(child, row, col)
             widgets.append(child)
         self.widgets.append(widgets)
     if self.uniform.pytype == float and rows == 1 and cols in [3, 4]:
         self.colorPicker = gui.ColorPickButton(material.Color().copyFrom(values[0,:3]))
         @self.colorPicker.mhEvent
         def onClicked(color):
             for idx,widget in enumerate(self.widgets[0][:3]):
                 widget.setValue(color.asTuple()[idx])
             self.callEvent('onActivate', color)
         self.addWidget(self.colorPicker, 1, 0)
예제 #2
0
    def __init__(self, name, value):
        super(ColorValue, self).__init__(name)
        self.name = name

        self.widgets = []
        for col in range(3):
            child = FloatValue(self, 0)
            self.addWidget(child, 0, col)
            self.widgets.append(child)
        self.pickBtn = self.addWidget(gui.ColorPickButton(value))
        @self.pickBtn.mhEvent
        def onClicked(color):
            self.value = color
            self.callEvent('onActivate', self.getValue())

        self.value = value
예제 #3
0
    def __init__(self, name, value = [0.0, 0.0, 0.0], isColor = False):
        super(VectorInput, self).__init__(name)
        self.name = name

        self.widgets = []
        for idx,v in enumerate(value):
            w = FloatValue(self, v)
            self.widgets.append(w)
            self.addWidget(w, 0, idx)
        self._value = value

        if isColor:
            self.colorPicker = gui.ColorPickButton(value)
            @self.colorPicker.mhEvent
            def onClicked(color):
                self.setValue(list(color.asTuple()))
            self.addWidget(self.colorPicker, 1, 0)
        else:
            self.colorPicker = None