Esempio n. 1
0
    def _update_active_layout_font_properties(self):
        family = self.font_families[self.font_select.get_active()]
        _titler_data.active_layer.font_family = family.get_name()

        _titler_data.active_layer.font_size = self.size_spin.get_value_as_int()

        face = FACE_REGULAR
        if self.bold_font.get_active() and self.italic_font.get_active():
            face = FACE_BOLD_ITALIC
        elif self.italic_font.get_active():
            face = FACE_ITALIC
        elif self.bold_font.get_active():
            face = FACE_BOLD
        _titler_data.active_layer.font_face = face

        align = ALIGN_LEFT
        if self.center_align.get_active():
            align = ALIGN_CENTER
        elif self.right_align.get_active():
            align = ALIGN_RIGHT
        _titler_data.active_layer.alignment = align

        color = self.color_button.get_color()
        r, g, b = utils.hex_to_rgb(color.to_string())
        new_color = (r / 65535.0, g / 65535.0, b / 65535.0, 1.0)
        _titler_data.active_layer.color_rgba = new_color
        _titler_data.active_layer.fill_on = self.fill_on.get_active()

        # OUTLINE
        color = self.out_line_color_button.get_color()
        r, g, b = utils.hex_to_rgb(color.to_string())
        new_color2 = (r / 65535.0, g / 65535.0, b / 65535.0, 1.0)
        _titler_data.active_layer.outline_color_rgba = new_color2
        _titler_data.active_layer.outline_on = self.outline_on.get_active()
        _titler_data.active_layer.outline_width = self.out_line_size_spin.get_value(
        )

        # SHADOW
        color = self.shadow_color_button.get_color()
        r, g, b = utils.hex_to_rgb(color.to_string())
        a = self.shadow_opa_spin.get_value() / 100.0
        new_color3 = (r / 65535.0, g / 65535.0, b / 65535.0)
        _titler_data.active_layer.shadow_color_rgb = new_color3
        _titler_data.active_layer.shadow_on = self.shadow_on.get_active()
        _titler_data.active_layer.shadow_opacity = self.shadow_opa_spin.get_value(
        )
        _titler_data.active_layer.shadow_xoff = self.shadow_xoff_spin.get_value(
        )
        _titler_data.active_layer.shadow_yoff = self.shadow_yoff_spin.get_value(
        )

        self.view_editor.active_layer.update_rect = True
        _titler_data.active_layer.update_pango_layout()
Esempio n. 2
0
    def _update_active_layout_font_properties(self):
        family = self.font_families[self.font_select.get_active()]
        _titler_data.active_layer.font_family = family.get_name()

        _titler_data.active_layer.font_size = self.size_spin.get_value_as_int()
        
        face = FACE_REGULAR
        if self.bold_font.get_active() and self.italic_font.get_active():
            face = FACE_BOLD_ITALIC
        elif self.italic_font.get_active():
            face = FACE_ITALIC
        elif self.bold_font.get_active():
            face = FACE_BOLD
        _titler_data.active_layer.font_face = face
        
        align = ALIGN_LEFT
        if self.center_align.get_active():
            align = ALIGN_CENTER
        elif  self.right_align.get_active():
             align = ALIGN_RIGHT
        _titler_data.active_layer.alignment = align

        color = self.color_button.get_color()
        r, g, b = utils.hex_to_rgb(color.to_string())
        new_color = (r/65535.0, g/65535.0, b/65535.0, 1.0)        
        _titler_data.active_layer.color_rgba = new_color
        _titler_data.active_layer.fill_on = self.fill_on.get_active()
        
        # OUTLINE
        color = self.out_line_color_button.get_color()
        r, g, b = utils.hex_to_rgb(color.to_string())
        new_color2 = (r/65535.0, g/65535.0, b/65535.0, 1.0)    
        _titler_data.active_layer.outline_color_rgba = new_color2
        _titler_data.active_layer.outline_on = self.outline_on.get_active()
        _titler_data.active_layer.outline_width = self.out_line_size_spin.get_value()

        # SHADOW
        color = self.shadow_color_button.get_color()
        r, g, b = utils.hex_to_rgb(color.to_string())
        a = self.shadow_opa_spin.get_value() / 100.0
        new_color3 = (r/65535.0, g/65535.0, b/65535.0)  
        _titler_data.active_layer.shadow_color_rgb = new_color3
        _titler_data.active_layer.shadow_on = self.shadow_on.get_active()
        _titler_data.active_layer.shadow_opacity = self.shadow_opa_spin.get_value()
        _titler_data.active_layer.shadow_xoff = self.shadow_xoff_spin.get_value()
        _titler_data.active_layer.shadow_yoff = self.shadow_yoff_spin.get_value()
                
        self.view_editor.active_layer.update_rect = True
        _titler_data.active_layer.update_pango_layout()
Esempio n. 3
0
 def drawRects(self, hex_colors):
     assert len(hex_colors) == len(self.locations)
     for hex_color, loc in zip(hex_colors, self.locations):
         rgbtuple = utils.hex_to_rgb(hex_color)
         self.qp.setBrush(QtGui.QColor(*rgbtuple))
         self.qp.drawRect(loc[1] * self.stride + 10,
                          loc[0] * self.stride + 10, self.size, self.size)
Esempio n. 4
0
 def __init__(self, **kwargs):
     """
     :param hex: 'RRGGBB'
     :param r: 0 - 255
     :param g: 0 - 255
     :param b: 0 - 255
     :param h: 0 - 360
     :param s: 0 - 100
     :param v: 0 - 100
     """
     if 'hex' in kwargs:
         hex_code = kwargs.get('hex')
         self._color = hex_to_rgb(hex_code)
     elif 'r' in kwargs and 'g' in kwargs and 'b' in kwargs:
         r = bracket(kwargs.get('r'))
         g = bracket(kwargs.get('g'))
         b = bracket(kwargs.get('b'))
         self._color = r, g, b
     elif 'h' in kwargs and 's' in kwargs and 'v' in kwargs:
         h = bracket(kwargs.get('h'), 0, 360)
         s = bracket(kwargs.get('s'), 0, 100)
         v = bracket(kwargs.get('v'), 0, 100)
         r, g, b = hsv_to_rgb(h / 360.0, s / 100.0, v / 100.0)
         self._color = (int(r * 255.0 + 0.5), int(g * 255.0 + 0.5),
                        int(b * 255.0 + 0.5))
     else:
         self._color = 0, 0, 0
Esempio n. 5
0
def by_hex(color_name) -> 'html':
    # extract RGB
    r, g, b = utils.hex_to_rgb(color_name)
    #
    msg = 'Color: #{}; RGB({}, {}, {}); '.format(color_name, r, g, b)
    # make a sorted array
    cp_colors = copy.copy(tikkurila_colors.COLORS)
    for clr in cp_colors:
        clr[4] = abs(clr[0] - r) + abs(clr[1] - g) + abs(clr[2] - b)
    # sort
    from operator import itemgetter
    cp_colors.sort(key=itemgetter(4))
    # hsl
    h, l, s = colorsys.rgb_to_hls(r, g, b)
    msg += 'HLS: {0:.3f}, {1:.3f}, {2:.3f}.'.format(h, l, s)
    # result
    return render_template(
        'color_by_hex.html',
        the_title=TITLE,
        the_note='',
        the_result='',
        the_name_color0=msg,
        the_color0=utils.rgb_to_hex(r, g, b),
        the_color1=utils.rgb_to_hex(cp_colors[0][0], cp_colors[0][1],
                                    cp_colors[0][2]),
        the_color2=utils.rgb_to_hex(cp_colors[1][0], cp_colors[1][1],
                                    cp_colors[1][2]),
        the_color3=utils.rgb_to_hex(cp_colors[2][0], cp_colors[2][1],
                                    cp_colors[2][2]),
        the_name_color1=cp_colors[0][3],
        the_name_color2=cp_colors[1][3],
        the_name_color3=cp_colors[2][3],
    )
Esempio n. 6
0
    def addNewTrace(self):
        '''
        fill the table with the parameters added in the dialog
        '''
        row = self.traceTable.rowCount()
        self.traceTable.insertRow(row)

        # fill the table with each paramter entered
        self.traceTable.setItem(row, 0, QTableWidgetItem(str(self.index)))
        self.traceTable.setItem(row, 1, QTableWidgetItem(str(self.LayerCombo.currentText())))
        self.traceTable.setItem(row, 2, QTableWidgetItem(str(self.expField1.currentText())))
        self.traceTable.setItem(row, 3, QTableWidgetItem(str(self.colorButton.color().name())))

        self.index += 1


        # get layer and the selected fields (signals and update directly in the UI)


        # QgsVectorLayer
        lay1 = self.expField1.layer()
        # name of the field of the QgsVectorLayer
        lay1_f = self.expField1.currentText()


        # build the lists from the selected fields
        f1 = []

        # loop to use normal field or selected expression for first layer
        if self.expField1.currentField()[1] == False:
            for i in lay1.getFeatures():
                f1.append(i[lay1_f])
        else:
            filter1 = self.expField1.currentField()[0]
            exp1 = QgsExpression(filter1)
            for i in lay1.getFeatures():
                f1.append(exp1.evaluate(i, lay1.pendingFields()))


        # get the hex code from the button
        colorhex = self.colorButton.color().name()

        # convert the hex code to a rgb tuple
        colorrgb = hex_to_rgb(colorhex)


        # create dictionary with all the plot parameters (each time the button is clicked a ner dictionary is added as VALUE to the initial dictionary)

        self.plot_param = dict()
        self.plot_param["index"] = self.index
        self.plot_param["layer"] = self.LayerCombo.currentLayer()
        self.plot_param["Field"]= f1
        self.plot_param["Color"] = colorrgb
        self.plot_param["Name"] = self.expField1.currentText()


        # add the dictionary with plot values to the initial dictionary
        self.superdict[row] = self.plot_param
Esempio n. 7
0
 def color_selected(self, color_button):
     color = color_button.get_color()
     value = utils.hex_to_rgb(color.to_string())
     raw_r, raw_g, raw_b = value
     val_str = "#" + utils.int_to_hex(int((float(raw_r) * 255.0) / 65535.0)) + \
                     utils.int_to_hex(int((float(raw_g) * 255.0) / 65535.0)) + \
                     utils.int_to_hex(int((float(raw_b) * 255.0) / 65535.0))
                     
     self.write_value(val_str)
Esempio n. 8
0
 def draw(self, screen):
     for y, row in enumerate(self.grid.grid.transpose()):
         x = 0
         for x, v in enumerate(row):
             cell = self.grid.cells[v]
             color = cell.color
             # color = cell.color if not cell.is_walkable else '#ffffff'
             screen.fill(hex_to_rgb(color),
                         (self.x + x * self.size + 1, self.y +
                          y * self.size + 1, self.size - 1, self.size - 1))
Esempio n. 9
0
    def _update_active_layout(self, fill_layers_data_if_needed=True):
        if self.block_updates:
            return

        global _titler_data
        buf = self.text_view.get_buffer()
        text = buf.get_text(buf.get_start_iter(),
                            buf.get_end_iter(),
                            include_hidden_chars=True)
        if text != _titler_data.active_layer.text:
            update_layers_list = True
        else:
            update_layers_list = False

        _titler_data.active_layer.text = text

        family = self.font_families[self.font_select.get_active()]
        _titler_data.active_layer.font_family = family.get_name()

        _titler_data.active_layer.font_size = self.size_spin.get_value_as_int()

        face = FACE_REGULAR
        if self.bold_font.get_active() and self.italic_font.get_active():
            face = FACE_BOLD_ITALIC
        elif self.italic_font.get_active():
            face = FACE_ITALIC
        elif self.bold_font.get_active():
            face = FACE_BOLD
        _titler_data.active_layer.font_face = face

        align = ALIGN_LEFT
        if self.center_align.get_active():
            align = ALIGN_CENTER
        elif self.right_align.get_active():
            align = ALIGN_RIGHT
        _titler_data.active_layer.alignment = align

        color = self.color_button.get_color()
        r, g, b = utils.hex_to_rgb(color.to_string())
        new_color = (r / 65535.0, g / 65535.0, b / 65535.0, 1.0)
        _titler_data.active_layer.color_rgba = new_color

        self.view_editor.active_layer.update_rect = True
        _titler_data.active_layer.update_pango_layout()

        # We only wnat to update layer list data model when this called after user typing
        if update_layers_list:
            self.layer_list.fill_data_model()

        self.view_editor.edit_area.queue_draw()
Esempio n. 10
0
    async def role_colour(self, ctx: utils.CustomContext, role: Role,
                          colour: str):
        """Sets the colour of a given role."""

        hex_regex = r"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"

        if not re.match(hex_regex, colour):
            return await ctx.send(
                "The colour must be a properly formed **hex** colour.")

        hex_to_rgb = utils.hex_to_rgb(colour[1:])
        colour = discord.Colour.from_rgb(hex_to_rgb[0], hex_to_rgb[1],
                                         hex_to_rgb[2])
        await role.edit(colour=colour)
        await ctx.thumbsup()
Esempio n. 11
0
    def _update_active_layout(self, fill_layers_data_if_needed=True):
        if self.block_updates:
            return

        global _titler_data
        buf = self.text_view.get_buffer()
        text = buf.get_text(buf.get_start_iter(), buf.get_end_iter(), include_hidden_chars=True)
        if text != _titler_data.active_layer.text:
            update_layers_list = True
        else:
            update_layers_list = False

        _titler_data.active_layer.text = text
        
        family = self.font_families[self.font_select.get_active()]
        _titler_data.active_layer.font_family = family.get_name()

        _titler_data.active_layer.font_size = self.size_spin.get_value_as_int()
        
        face = FACE_REGULAR
        if self.bold_font.get_active() and self.italic_font.get_active():
            face = FACE_BOLD_ITALIC
        elif self.italic_font.get_active():
            face = FACE_ITALIC
        elif self.bold_font.get_active():
            face = FACE_BOLD
        _titler_data.active_layer.font_face = face
        
        align = ALIGN_LEFT
        if self.center_align.get_active():
            align = ALIGN_CENTER
        elif  self.right_align.get_active():
             align = ALIGN_RIGHT
        _titler_data.active_layer.alignment = align

        color = self.color_button.get_color()
        r, g, b = utils.hex_to_rgb(color.to_string())
        new_color = (r/65535.0, g/65535.0, b/65535.0, 1.0)        
        _titler_data.active_layer.color_rgba = new_color

        self.view_editor.active_layer.update_rect = True
        _titler_data.active_layer.update_pango_layout()

        # We only wnat to update layer list data model when this called after user typing 
        if update_layers_list:
            self.layer_list.fill_data_model()

        self.view_editor.edit_area.queue_draw()
Esempio n. 12
0
    def get(self, query_string):
        """
        query_string : string
            5 colour input palette as hex format string
            no #s, 5 colours of len  6, total len 30, no delimiters
            eg 'bbafa557534d383530726b63958b81'
        """
        query_palette = [query_string[i:i + 6] for i in range(0, 30, 6)]
        rgb_palette = np.array(
            [hex_to_rgb(colour) for colour in query_palette])
        palette = rgb_to_lab(rgb_palette)

        distances = (np.linalg.norm(all_possible_palettes - palette,
                                    axis=3).sum(axis=2).min(axis=1))

        palette_distances = pd.Series(dict(zip(image_ids, distances)))
        most_similar_ids = (
            palette_distances.sort_values()[1:13].index.values.tolist())

        return jsonify({
            'request': query_palette,
            'response': ids_to_urls(most_similar_ids)
        })
Esempio n. 13
0
 def get_value_rgba(self):
     raw_r, raw_g, raw_b = utils.hex_to_rgb(self.value)
     return (float(raw_r)/255.0, float(raw_g)/255.0, float(raw_b)/255.0, 1.0)
Esempio n. 14
0
 def get_value_as_gdk_color(self):
     raw_r, raw_g, raw_b = utils.hex_to_rgb(self.value)
     return Gdk.Color(red=(float(raw_r)/255.0),
                          green=(float(raw_g)/255.0),
                          blue=(float(raw_b)/255.0))
def _color_hex_to_tuple(value, natron_node, natron_property_name, args):
    r, g, b = utils.hex_to_rgb(value)
    interpreted_value = ".set(" + str(float(r) / 255.0) + ", " + str(
        float(g) / 255.0) + ", " + str(float(b) / 255.0) + ", 1.0)"
    return _get_modification_target(
        natron_node, natron_property_name) + interpreted_value + NEWLINE
Esempio n. 16
0
class Mundim(App):
    colors = DictProperty({
        'black': hex_to_rgb('000000'),
        'white': hex_to_rgb('FFFFFF'),
        'off_white': hex_to_rgb('F3F3F3'),
        'blue_1': hex_to_rgb('73B9E8'),
        'green_1': hex_to_rgb('73E89A'),
        'debug': hex_to_rgb('FF0000')[:3] + [0.1],
    })

    patients_ammount = NumericProperty(-1)
    patients = ListProperty([])

    no_prognostic_patients_ammount = NumericProperty(-1)
    no_prognostic_patients = ListProperty([])

    def load_patients(self, threaded=False, delay=0):
        def _load_patients():
            patients = load_query("SELECT * FROM patients")
            for patient in patients:
                patient['size_hint'] = [None, None]
                patient['size'] = dp(300), dp(50)

            self.patients = patients
            self.patients_ammount = len(self.patients)

        if delay:
            Clock.schedule_once(
                (lambda x: self.load_patients(threaded=threaded)), delay
            )
            return

        if threaded:
            Thread(target=_load_patients, args=[]).start()
        else:
            _load_patients()

    def on_patients(self, instance, value):
        no_prognostic_patients = []
        for patient in value:
            if patient['biopsy_diagnostic'] == '':
                no_prognostic_patients.append(patient)
        self.no_prognostic_patients = no_prognostic_patients
        self.no_prognostic_patients_ammount = len(self.no_prognostic_patients)

    def on_start(self):
        from kivy.base import EventLoop
        EventLoop.window.bind(on_keyboard=self.hook_keyboard)

        self.load_patients(threaded=True, delay=1)
        Clock.schedule_interval(lambda x: self.load_patients(threaded=True), 60)
        if platform == 'android':
            set_statusbar_color('#FFFFFF')

    @staticmethod
    def check_request_permission():
        if platform != "android":
            return
        from android.permissions import (
            Permission, request_permission, check_permission)
        permission = Permission.CAMERA
        if not check_permission(permission):
            request_permission(permission)

    def hook_keyboard(self, window, key, *largs):
        if key == 27:
            self.root.undo()
            return True

    def build(self):
        self.check_request_permission()

        self.root = MundimRoot()
        self.root.app = self
        return self.root
Esempio n. 17
0
    def addNewTrace(self):
        '''
        fill the table with the parameters added in the dialog
        '''
        row = self.traceTable.rowCount()
        self.traceTable.insertRow(row)

        # fill the table with each paramter entered
        self.traceTable.setItem(row, 0, QTableWidgetItem(str(self.index)))
        self.traceTable.setItem(row, 1, QTableWidgetItem(str(self.LayerCombo.currentText())))
        self.traceTable.setItem(row, 2, QTableWidgetItem(str(self.expField1.currentText())))
        self.traceTable.setItem(row, 3, QTableWidgetItem(str(self.colorButton.color().name())))
        self.traceTable.setItem(row, 4, QTableWidgetItem(str(self.alpha.value())))

        self.index += 1


        # get layer and the selected fields (signals and update directly in the UI)


        # QgsVectorLayer
        lay1 = self.expField1.layer()
        # name of the field of the QgsVectorLayer
        lay1_f = self.expField1.currentText()


        # build the lists from the selected fields
        f1 = []

        # loop to use normal field or selected expression for first layer
        if self.expField1.currentField()[1] == False:
            for i in lay1.getFeatures():
                f1.append(i[lay1_f])
        else:
            filter1 = self.expField1.currentField()[0]
            exp1 = QgsExpression(filter1)
            for i in lay1.getFeatures():
                f1.append(exp1.evaluate(i, lay1.pendingFields()))



        # get the hex code from the button
        colorhex = self.colorButton.color().name()

        # convert the hex code to a rgb tuple
        colorrgb = hex_to_rgb(colorhex)


        # value of the slider for the alpha channel
        alphavalue = self.alpha.value()


        # create dictionary with all the plot parameters (each time the button is clicked a ner dictionary is added as VALUE to the initial dictionary)

        self.plot_param = dict()
        self.plot_param["index"] = self.index
        self.plot_param["layer"] = (self.LayerCombo.currentLayer())
        self.plot_param["Field"]= f1
        self.plot_param["Color"] = colorrgb
        self.plot_param["Transparency"] = alphavalue
        self.plot_param["Name"] = self.expField1.currentText()



        # add the dictionary with plot values to the initial dictionary
        self.superdict[row] = self.plot_param
Esempio n. 18
0
 def get_value_as_gdk_color(self):
     raw_r, raw_g, raw_b = utils.hex_to_rgb(self.value)
     return Gdk.Color(red=(float(raw_r) / 255.0),
                      green=(float(raw_g) / 255.0),
                      blue=(float(raw_b) / 255.0))
Esempio n. 19
0
    def addNewTrace(self):
        '''
        fill the table with the parameters added in the dialog
        '''
        row = self.traceTable.rowCount()
        self.traceTable.insertRow(row)

        # fill the table with each paramter entered
        self.traceTable.setItem(row, 0, QTableWidgetItem(str(self.index)))
        self.traceTable.setItem(
            row, 1, QTableWidgetItem(str(self.LayerCombo.currentText())))
        self.traceTable.setItem(
            row, 2, QTableWidgetItem(str(self.expField1.currentText())))
        self.traceTable.setItem(
            row, 3, QTableWidgetItem(str(self.expField2.currentText())))
        if self.dataDefined.isActive():
            self.traceTable.setItem(
                row, 4, QTableWidgetItem(str(self.dataDefined.getField())))
        else:
            self.traceTable.setItem(row, 4,
                                    QTableWidgetItem(str(self.Size.value())))
        self.traceTable.setItem(
            row, 5, QTableWidgetItem(str(self.colorButton.color().name())))
        self.traceTable.setItem(row, 6,
                                QTableWidgetItem(str(self.alpha.value())))

        self.index += 1

        # get layer and the selected fields (signals and update directly in the UI)

        # QgsVectorLayer
        lay1 = self.expField1.layer()
        # name of the field of the QgsVectorLayer
        lay1_f = self.expField1.currentText()
        # QgsVectorLayer
        lay2 = self.expField2.layer()
        # name of the field of the QgsVectorLayer
        lay2_f = self.expField2.currentText()

        # build the lists from the selected fields
        f1 = []
        f2 = []

        # loop to use normal field or selected expression for first layer
        if self.expField1.currentField()[1] == False:
            for i in lay1.getFeatures():
                f1.append(i[lay1_f])
        else:
            filter1 = self.expField1.currentField()[0]
            exp1 = QgsExpression(filter1)
            for i in lay1.getFeatures():
                f1.append(exp1.evaluate(i, lay1.pendingFields()))

        # loop to use normal field or selected expression for second layer
        if self.expField2.currentField()[1] == False:
            for i in lay2.getFeatures():
                f2.append(i[lay2_f])
        else:
            filter2 = self.expField2.currentField()[0]
            exp2 = QgsExpression(filter2)
            for i in lay2.getFeatures():
                f2.append(exp2.evaluate(i, lay2.pendingFields()))

        # get the hex code from the button
        colorhex = self.colorButton.color().name()

        # convert the hex code to a rgb tuple
        colorrgb = hex_to_rgb(colorhex)

        # color for the outline line
        colorhex2 = self.colorButton2.color().name()

        # convert the hex code to a rgb tuple
        colorrgb2 = hex_to_rgb(colorhex2)

        # value of the slider for the alpha channel
        alphavalue = self.alpha.value()

        # size settings
        if self.dataDefined.isActive() == False:
            markSize = self.Size.value()
        else:
            markSize = []
            if self.dataDefined.useExpression() == True:
                sizefilter = self.dataDefined.getExpression()
                sizeexp = QgsExpression(sizefilter)
                for i in self.LayerCombo.currentLayer().getFeatures():
                    markSize.append(
                        sizeexp.evaluate(
                            i,
                            self.LayerCombo.currentLayer().pendingFields()))
            else:
                for i in self.LayerCombo.currentLayer().getFeatures():
                    markSize.append(i[self.dataDefined.getField()])

        # create dictionary with all the plot parameters (each time the button is clicked a ner dictionary is added as VALUE to the initial dictionary)

        self.plot_param = dict()
        self.plot_param["index"] = self.index
        self.plot_param["layer"] = (self.LayerCombo.currentLayer())
        self.plot_param["R"] = f1
        self.plot_param["T"] = f2
        self.plot_param["Size"] = markSize
        self.plot_param["Color"] = colorrgb
        self.plot_param["OutLine_Color"] = colorrgb2
        self.plot_param["Transparency"] = alphavalue
        self.plot_param["Name"] = self.expField2.currentText()

        # add the dictionary with plot values to the initial dictionary
        self.superdict[row] = self.plot_param
Esempio n. 20
0
 def __init__(self, x=0, y=0, size=5, color='#000000'):
     self.size = size
     self.x = x
     self.y = y
     self.color = hex_to_rgb(color)
Esempio n. 21
0
 def __init__(self, background='#ffffff', size=[1024, 768]):
     self.drawers = []
     self.size = size
     self.background = hex_to_rgb(background)
Esempio n. 22
0
 def fetch_rgb(self):
     hex_colors, freq_staleness = self.get_hex_arr()
     for i, hex_color in enumerate(hex_colors):
         rgbtuple = utils.hex_to_rgb(hex_color)
         self.data[3 * i:3 * i + 3] = rgbtuple
Esempio n. 23
0
def _color_hex_to_tuple(value, natron_node, natron_property_name, args):    
    r, g, b = utils.hex_to_rgb(value)
    interpreted_value = ".set(" + str(float(r)/255.0) + ", " + str(float(g)/255.0)  + ", " + str(float(b)/255.0)  + ", 1.0)"
    return _get_modification_target(natron_node, natron_property_name) + interpreted_value + NEWLINE
Esempio n. 24
0
 def __init__(self, x, y, color='#000000', width=5, size=25):
     self.x = x
     self.y = y
     self.color = hex_to_rgb(color)
     self.size = size
     self.width = width
Esempio n. 25
0
    def addNewTrace(self):
        '''
        fill the table with the parameters added in the dialog
        '''
        row = self.traceTable.rowCount()
        self.traceTable.insertRow(row)

        # fill the table with each paramter entered
        self.traceTable.setItem(row, 0, QTableWidgetItem(str(self.index)))
        self.traceTable.setItem(row, 1, QTableWidgetItem(str(self.LayerCombo.currentText())))
        self.traceTable.setItem(row, 2, QTableWidgetItem(str(self.expField1.currentText())))
        self.traceTable.setItem(row, 3, QTableWidgetItem(str(self.expField2.currentText())))
        if self.dataDefined.isActive():
            self.traceTable.setItem(row, 4, QTableWidgetItem(str(self.dataDefined.getField())))
        else:
            self.traceTable.setItem(row, 4, QTableWidgetItem(str(self.Size.value())))
        self.traceTable.setItem(row, 5, QTableWidgetItem(str(self.symbolCombo.currentText())))
        self.traceTable.setItem(row, 6, QTableWidgetItem(str(self.colorButton.color().name())))
        self.traceTable.setItem(row, 7, QTableWidgetItem(str(self.alpha.value())))

        self.index += 1


        # get layer and the selected fields (signals and update directly in the UI)


        # QgsVectorLayer
        lay1 = self.expField1.layer()
        # name of the field of the QgsVectorLayer
        lay1_f = self.expField1.currentText()
        # QgsVectorLayer
        lay2 = self.expField2.layer()
        # name of the field of the QgsVectorLayer
        lay2_f = self.expField2.currentText()


        # build the lists from the selected fields
        f1 = []
        f2 = []

        # cicle to use normal field or selected expression for first layer
        if self.expField1.currentField()[1] == False:
            for i in lay1.getFeatures():
                f1.append(i[lay1_f])
        else:
            filter1 = self.expField1.currentField()[0]
            exp1 = QgsExpression(filter1)
            for i in lay1.getFeatures():
                f1.append(exp1.evaluate(i, lay1.pendingFields()))

        # cicle to use normal field or selected expression for second layer
        if self.expField2.currentField()[1] == False:
            for i in lay2.getFeatures():
                f2.append(i[lay2_f])
        else:
            filter2 = self.expField2.currentField()[0]
            exp2 = QgsExpression(filter2)
            for i in lay2.getFeatures():
                f2.append(exp2.evaluate(i, lay2.pendingFields()))


        # get the hex code from the button
        colorhex = self.colorButton.color().name()

        # convert the hex code to a rgb tuple
        colorrgb = hex_to_rgb(colorhex)

        # color for the outline line
        colorhex2 = self.colorButton2.color().name()

        # convert the hex code to a rgb tuple
        colorrgb2 = hex_to_rgb(colorhex2)


        # value of the slider for the alpha channel
        alphavalue = self.alpha.value()


        # size settings
        if self.dataDefined.isActive() == False:
            markSize = self.Size.value()
        else:
            markSize = []
            if self.dataDefined.useExpression() == True:
                sizefilter = self.dataDefined.getExpression()
                sizeexp = QgsExpression(sizefilter)
                for i in self.LayerCombo.currentLayer().getFeatures():
                    markSize.append(sizeexp.evaluate(i, self.LayerCombo.currentLayer().pendingFields()))
            else:
                for i in self.LayerCombo.currentLayer().getFeatures():
                    markSize.append(i[self.dataDefined.getField()])


        # symbol choice
        symbol = self.symbolCombo.currentText()



        # create dictionary with all the plot parameters (each time the button is clicked a ner dictionary is added as VALUE to the initial dictionary)

        self.plot_param = dict()
        self.plot_param["index"] = self.index
        self.plot_param["layer"] = (self.LayerCombo.currentLayer())
        self.plot_param["X"]= f1
        self.plot_param["Y"] = f2
        self.plot_param["Size"]= markSize
        self.plot_param["Marker"] = symbol
        self.plot_param["Color"] = colorrgb
        self.plot_param["OutLine_Color"] = colorrgb2
        self.plot_param["OutLine_Width"] = self.widthBox.value()
        self.plot_param["Transparency"] = alphavalue
        self.plot_param["Name"] = self.expField2.currentText()



        # add the dictionary with plot values to the initial dictionary
        self.superdict[row] = self.plot_param
Esempio n. 26
0
 def card_background(self):
     """Turns hex and opacity to RBGA Tuple"""
     return utils.hex_to_rgb(self.card_bg[0]) + (self.card_bg[1], )
Esempio n. 27
0
 def get_value_rgba(self):
     raw_r, raw_g, raw_b = utils.hex_to_rgb(self.value)
     return (float(raw_r) / 255.0, float(raw_g) / 255.0,
             float(raw_b) / 255.0, 1.0)
Esempio n. 28
0
def draw_experiment_label(experiment_info):
    # create group
    experiment_label = bpy.data.objects.new("experiment_label", None)
    bpy.context.scene.objects.link(experiment_label)

    # define some positions and parameters
    x = experiment_info["x"] + experiment_info["w"] / 2
    y = -0.51
    z = -2
    z_text_offset = 0.5
    width = experiment_info["w"]
    depth = 2
    extrusion = 1

    # add text
    bpy.ops.object.text_add()
    obj = bpy.context.scene.objects[0]
    obj.data.font = font
    obj.data.body = experiment_info["experiment"]
    obj.data.align_x = "CENTER"
    obj.data.align_y = "CENTER"
    obj.data.edit_format.use_bold = True
    obj.location = Vector((x, y - extrusion - 0.05, z + z_text_offset))
    obj.rotation_euler = Vector((np.pi / 2, 0, 0))
    obj.data.size = 1.7

    obj.parent = experiment_label

    color = utils.hex_to_rgb(experiment_info["color"])

    # text color
    mat = bpy.data.materials.new('Material')
    mat.diffuse_color = color
    mat.diffuse_intensity = 0.4
    obj.data.materials.append(mat)

    # draw box
    bm = bmesh.new()
    face = bm.faces.new([
        bm.verts.new([x - width / 2, y, z - depth / 2]),
        bm.verts.new([x + width / 2, y, z - depth / 2]),
        bm.verts.new([x + width / 2, y, z + depth / 2]),
        bm.verts.new([x - width / 2, y, z + depth / 2])
    ])

    # extrude
    bmesh.ops.recalc_face_normals(bm, faces=[face])
    r = bmesh.ops.extrude_discrete_faces(bm, faces=[face])
    f = r['faces'][0]
    bmesh.ops.translate(bm, vec=Vector((0, -extrusion, 0)), verts=f.verts)

    obj = create_object(bm)

    obj.parent = experiment_label

    # box color
    color = [.9, .9, .9]

    mat = bpy.data.materials.new('Material')
    mat.diffuse_color = color
    mat.diffuse_intensity = 0.7
    obj.data.materials.append(mat)

    return experiment_label