Пример #1
0
 def _number_of_colors_changed(self, value):
     if self.lut_mode == 'file':
         return
     elif self.lut_mode in pylab_luts:
         # We can't interpolate these LUTs, as they are defined from a
         # table. We hack around this limitation
         reverse = self.reverse_lut
         lut = pylab_luts[self.lut_mode]
         if reverse:
             lut = lut[::-1, :]
         n_total = len(lut)
         if value > n_total:
             return
         lut = lut[::int(round(n_total/float(value)))]
         self.load_lut_from_list(lut.tolist())
     else:
         lut = self.lut
         lut.number_of_table_values = value
         lut.modified()
         lut.build()
         self.render() # necessary to flush.
     sc_bar = self.scalar_bar
     sc_bar.maximum_number_of_colors = value
     sc_bar.modified()
     self.render()
Пример #2
0
 def _number_of_colors_changed(self, value):
     if self.lut_mode == 'file':
         return
     elif self.lut_mode in pylab_luts:
         # We can't interpolate these LUTs, as they are defined from a
         # table. We hack around this limitation
         reverse = self.reverse_lut
         lut = pylab_luts[self.lut_mode]
         if reverse:
             lut = lut[::-1, :]
         n_total = len(lut)
         if value > n_total:
             return
         lut = lut[::round(n_total / float(value))]
         self.load_lut_from_list(lut.tolist())
     else:
         lut = self.lut
         lut.number_of_table_values = value
         lut.modified()
         lut.build()
         self.render()  # necessary to flush.
     sc_bar = self.scalar_bar
     sc_bar.maximum_number_of_colors = value
     sc_bar.modified()
     self.render()
Пример #3
0
    def _lut_mode_changed(self, value):

        if value == "file":
            if self.file_name:
                self.load_lut_from_file(self.file_name)
            # self.lut.force_build()
            return

        reverse = self.reverse_lut
        if value in pylab_luts:
            lut = pylab_luts[value]
            if reverse:
                lut = lut[::-1, :]
            n_total = len(lut)
            n_color = self.number_of_colors
            if not n_color >= n_total:
                lut = lut[:: round(n_total / float(n_color))]
            self.load_lut_from_list(lut.tolist())
            # self.lut.force_build()
            return
        elif value == "blue-red":
            if reverse:
                hue_range = 0.0, 0.6667
                saturation_range = 1.0, 1.0
                value_range = 1.0, 1.0
            else:
                hue_range = 0.6667, 0.0
                saturation_range = 1.0, 1.0
                value_range = 1.0, 1.0
        elif value == "black-white":
            if reverse:
                hue_range = 0.0, 0.0
                saturation_range = 0.0, 0.0
                value_range = 1.0, 0.0
            else:
                hue_range = 0.0, 0.0
                saturation_range = 0.0, 0.0
                value_range = 0.0, 1.0
        lut = self.lut
        lut.set(
            hue_range=hue_range,
            saturation_range=saturation_range,
            value_range=value_range,
            number_of_table_values=self.number_of_colors,
            ramp="sqrt",
        )
        lut.modified()
        lut.force_build()

        self.render()
Пример #4
0
    def _lut_mode_changed(self, value):

        if value == 'file':
            if self.file_name:
                self.load_lut_from_file(self.file_name)
            #self.lut.force_build()
            return

        reverse = self.reverse_lut
        if value in pylab_luts:
            lut = pylab_luts[value]
            if reverse:
                lut = lut[::-1, :]
            n_total = len(lut)
            n_color = self.number_of_colors
            if not n_color >= n_total:
                lut = lut[::round(n_total / float(n_color))]
            self.load_lut_from_list(lut.tolist())
            #self.lut.force_build()
            return
        elif value == 'blue-red':
            if reverse:
                hue_range = 0.0, 0.6667
                saturation_range = 1.0, 1.0
                value_range = 1.0, 1.0
            else:
                hue_range = 0.6667, 0.0
                saturation_range = 1.0, 1.0
                value_range = 1.0, 1.0
        elif value == 'black-white':
            if reverse:
                hue_range = 0.0, 0.0
                saturation_range = 0.0, 0.0
                value_range = 1.0, 0.0
            else:
                hue_range = 0.0, 0.0
                saturation_range = 0.0, 0.0
                value_range = 0.0, 1.0
        lut = self.lut
        lut.set(hue_range=hue_range,
                saturation_range=saturation_range,
                value_range=value_range,
                number_of_table_values=self.number_of_colors,
                ramp='sqrt')
        lut.modified()
        lut.force_build()

        self.render()