Exemplo n.º 1
0
 def add_pane(self, pane, x, y):
     pane.style['left'] = gui.to_pix(x)
     pane.style['top'] = gui.to_pix(y)
     pane.onclick.do(self.on_pane_selection)
     pane.style['position'] = 'absolute'
     self.append(pane)
     self.on_pane_selection(pane)
Exemplo n.º 2
0
 def on_dropped(self, left, top):
     try:
         self.refWidget.style['width'] = gui.to_pix(gui.from_pix(self.refWidget.style['width']) + gui.from_pix(left) - gui.from_pix(self.style['left']))
         self.refWidget.style['height'] = gui.to_pix(gui.from_pix(self.refWidget.style['height']) + gui.from_pix(top) - gui.from_pix(self.style['top']))
     except:
         pass
     self.update_position()
Exemplo n.º 3
0
 def update_position(self):
     if self.refWidget == None:
         return
     if self.refWidget.style['position'] != 'absolute' or (
             'right' in self.refWidget.style) or ('bottom'
                                                  in self.refWidget.style):
         self.style['display'] = 'none'
         return
     try:
         self.style['position'] = 'absolute'
         self.style['display'] = 'block'
         if ('left' in self.refWidget.style) and (
                 'top' in self.refWidget.style
         ) and ('height' in self.refWidget.style) and (
                 'width' in self.refWidget.style) and (
                     'height' in self.style) and ('width' in self.style):
             self.style['left'] = gui.to_pix(
                 gui.from_pix(self.refWidget.style['width']) +
                 gui.from_pix(self.refWidget.style['left']) -
                 gui.from_pix(self.style['width']) / 2)
             self.style['top'] = gui.to_pix(
                 gui.from_pix(self.refWidget.style['height']) +
                 gui.from_pix(self.refWidget.style['top']) -
                 gui.from_pix(self.style['height']) / 2)
     except:
         self.style['display'] = 'none'
Exemplo n.º 4
0
 def update_position(self):
     # print("RS Helper updating position")
     self.style['position']='absolute'
     self.style['left'] = \
         gui.to_pix(
             gui.from_pix(self.refWidget.style['left'])
         + from_px(
                 # self.refWidget.style['width']
                 self, 'width', self.parent
             )
         - from_px(
                 # self.style['width']
                 self, 'width', self.parent
             )/2)
     self.style['top'] = \
         gui.to_pix(
             gui.from_pix(self.refWidget.style['top'])
             + from_px(
                 # self.refWidget.style['height']
                 self, 'height', self.parent
             )
             - from_px(
                 # self.style['height']
                 self, 'height', self.parent
             )/2)
Exemplo n.º 5
0
 def add_pane(self, pane, x, y):
     pane.style['left'] = gui.to_pix(x)
     pane.style['top'] = gui.to_pix(y)
     pane.set_on_click_listener(self.on_pane_selection)
     pane.style['position'] = 'absolute'
     self.append(pane)
     self.on_pane_selection(pane)
Exemplo n.º 6
0
Arquivo: editor.py Projeto: CSCG/remi
 def on_dropped(self, left, top):
     self.refWidget.style['width'] = gui.to_pix(
         gui.from_pix(self.refWidget.style['width']) + gui.from_pix(left) -
         gui.from_pix(self.style['left']))
     self.refWidget.style['height'] = gui.to_pix(
         gui.from_pix(self.refWidget.style['height']) + gui.from_pix(top) -
         gui.from_pix(self.style['top']))
     self.update_position()
Exemplo n.º 7
0
 def update_position(self):
     self.style['position'] = 'absolute'
     self.style['left'] = gui.to_pix(
         gui.from_pix(self.refWidget.style['left']) -
         gui.from_pix(self.style['width']) / 2)
     self.style['top'] = gui.to_pix(
         gui.from_pix(self.refWidget.style['top']) -
         gui.from_pix(self.style['height']) / 2)
Exemplo n.º 8
0
 def onclick_search_logo(self, emitter):
     h, w, channels = self.logo_image.shape
     ok, x, y, similarity_result = image_utils.match_template(self.logo_image, self.camera_image.img, similarity=0.1)
     if ok: #la marca e' stata trovata
         self.selection_area_widget.style['left'] = gui.to_pix(x)
         self.selection_area_widget.style['top'] = gui.to_pix(y)
         self.selection_area_widget.style['width'] = gui.to_pix(w)
         self.selection_area_widget.style['height'] = gui.to_pix(h)
Exemplo n.º 9
0
 def update_position(self):
     self.style['position'] = 'absolute'
     if self.refWidget:
         if 'left' in self.refWidget.style and 'top' in self.refWidget.style:
             self.style['left'] = gui.to_pix(
                 gui.from_pix(self.refWidget.style['left']))
             self.style['top'] = gui.to_pix(
                 gui.from_pix(self.refWidget.style['top']))
Exemplo n.º 10
0
Arquivo: editor.py Projeto: CSCG/remi
 def update_position(self):
     if self.refWidget == None:
         return
     if self.refWidget.style['position'] != 'absolute':
         self.style['display'] = 'none'
         return
     self.style['position'] = 'absolute'
     self.style['display'] = 'block'
     self.style['left'] = gui.to_pix(gui.from_pix(self.refWidget.style['width'])+gui.from_pix(self.refWidget.style['left'])-gui.from_pix(self.style['width'])/2)
     self.style['top'] = gui.to_pix(gui.from_pix(self.refWidget.style['height'])+gui.from_pix(self.refWidget.style['top'])-gui.from_pix(self.style['height'])/2)
Exemplo n.º 11
0
    def new_project_tab(self, event):
        self.canvas.empty()
        f1 = gui.Widget()
        f1.add_class('w3-container z-depth-5')
        f1.style['width'] = '100%'
        f1.style['padding'] = '10px 10px'
        f1.style['background-color'] = config["primary-background-color"]
        
        foo = gui.Label('Project Name ')
        foo.style['color'] = config["primary-foreground-color"]
        foo.style['font-size'] = 'x-large'
        foo.style['padding'] = '10px 10px 10px 10px'

        project_name = gui.TextInput(hint='Enter your project name here')
        project_name.style['background-color'] = config["primary-background-color"]
        project_name.style['height'] = gui.to_pix(43)
        project_name.add_class('input-field waves-light')
        project_name.style['padding'] = gui.to_pix(10)

        ok_button = theme.EditorButton(text='Create', icon='add')

        def project_startup_page():
            self.canvas.empty()
            foo = gui.Label(project_name.get_text() + '.cxproj Project')
            foo.add_class('w3-jumbo')
            foo.style['height'] = '200px'
            foo.style['padding'] = '30px 30px 30px 30px'

            create_schematic_button = theme.EditorButton(text='Schematic', icon='edit')
            create_component_button = theme.EditorButton(text='Custom component definition', icon='edit')
            create_cppscript_button = theme.EditorButton(text='C++ Script', icon='edit')
            link_compiler_button = theme.EditorButton(text='Link custom compiler suite', icon='edit')
            lazy_populate_project_files(self, animate=False)

            for widget in [
                    foo, create_schematic_button,
                    create_component_button, create_cppscript_button,
                    link_compiler_button
                ]:
                self.canvas.append(widget)

        
        def project_event(e):
            project_format_file_handler = open(project_name.get_text() + '.cxproj', 'w')
            project_format_file_handler.write('')
            project_format_file_handler.close()
            project_startup_page()

        ok_button.onclick.do(project_event)

        for widget in [foo, project_name, ok_button]:
            f1.append(widget)
        
        for widget in [f1]:
            self.canvas.append(widget)
Exemplo n.º 12
0
 def on_drag(self, emitter, x, y):
     if self.active:
         if self.origin_x == -1:
             self.origin_x = float(x)
             self.origin_y = float(y)
             self.refWidget_origin_x = gui.from_pix(self.refWidget.style['left'])
             self.refWidget_origin_y = gui.from_pix(self.refWidget.style['top'])
         else:
             self.refWidget.style['left'] = gui.to_pix(self.refWidget_origin_x + float(x) - self.origin_x )
             self.refWidget.style['top'] = gui.to_pix(self.refWidget_origin_y + float(y) - self.origin_y)
             self.update_position()
Exemplo n.º 13
0
 def on_drag(self, emitter, x, y):
     if self.active:
         if self.origin_x == -1:
             self.origin_x = float(x)
             self.origin_y = float(y)
             self.refWidget_origin_w = gui.from_pix(self.refWidget.style['width'])
             self.refWidget_origin_h = gui.from_pix(self.refWidget.style['height'])
         else:
             self.refWidget.style['width'] = gui.to_pix( self.round_grid( self.refWidget_origin_w + float(x) - self.origin_x ) )
             self.refWidget.style['height'] = gui.to_pix( self.round_grid( self.refWidget_origin_h + float(y) - self.origin_y ) )
             self.update_position()
Exemplo n.º 14
0
 def on_drag(self, emitter, x, y):
     if self.active:
         if self.origin_x == -1:
             self.origin_x = float(x)
             self.origin_y = float(y)
             self.refWidget_origin_x = gui.from_pix(self.refWidget.style['left'])
             self.refWidget_origin_y = gui.from_pix(self.refWidget.style['top'])
         else:
             self.refWidget.style['left'] = gui.to_pix( self.round_grid( self.refWidget_origin_x + float(x) - self.origin_x ) )
             self.refWidget.style['top'] = gui.to_pix( self.round_grid( self.refWidget_origin_y + float(y) - self.origin_y ) )
             self.update_position()
Exemplo n.º 15
0
 def on_drag(self, emitter, x, y):
     if self.active:
         if self.origin_x == -1:
             self.origin_x = float(x)
             self.origin_y = float(y)
             self.refWidget_origin_w = gui.from_pix(self.refWidget.style['width'])
             self.refWidget_origin_h = gui.from_pix(self.refWidget.style['height'])
         else:
             self.refWidget.style['width'] = gui.to_pix(self.refWidget_origin_w + float(x) - self.origin_x )
             self.refWidget.style['height'] = gui.to_pix(self.refWidget_origin_h + float(y) - self.origin_y)
             self.update_position()
Exemplo n.º 16
0
 def __init__(self, width, height):
     super(SvgPlot, self).__init__(width, height)
     self.width = width
     self.height = height
     self.polyList = []
     self.font_size = 15
     self.plot_inner_border = self.font_size
     self.textYMin = gui.SvgText(0, self.height + self.font_size, "min")
     self.textYMax = gui.SvgText(0, 0, "max")
     self.textYMin.style['font-size'] = gui.to_pix(self.font_size)
     self.textYMax.style['font-size'] = gui.to_pix(self.font_size)
     self.append([self.textYMin, self.textYMax])
Exemplo n.º 17
0
 def __init__(self, width, height):
     super(SvgPlot, self).__init__(width, height)
     self.width = width
     self.height = height
     self.polyList = []
     self.font_size = 15
     self.plot_inner_border = self.font_size
     self.textYMin = gui.SvgText(0, self.height + self.font_size, "min")
     self.textYMax = gui.SvgText(0, 0, "max")
     self.textYMin.style['font-size'] = gui.to_pix(self.font_size)
     self.textYMax.style['font-size'] = gui.to_pix(self.font_size)
     self.append([self.textYMin, self.textYMax])
Exemplo n.º 18
0
 def on_drag(self, emitter, x, y):
     if self.active:
         if self.origin_x == -1:
             self.origin_x = int(x)
             self.origin_y = int(y)
             self.refWidget_origin_w = gui.from_pix(self.refWidget.style['width'])
             self.refWidget_origin_h = gui.from_pix(self.refWidget.style['height'])
         else:
             self.refWidget.style['width'] = gui.to_pix(self.refWidget_origin_w + int(x) - self.origin_x )
             self.refWidget.style['height'] = gui.to_pix(self.refWidget_origin_h + int(y) - self.origin_y)
             self.update_position()
         return self.eventManager.propagate(self.EVENT_ONDRAG, ())
Exemplo n.º 19
0
 def update_position(self):
     if self.refWidget == None:
         return
     if self.refWidget.style['position'] != 'absolute' or ('right' in self.refWidget.style) or ('bottom' in self.refWidget.style):
         self.style['display'] = 'none'
         return
     try:
         self.style['position'] = 'absolute'
         self.style['display'] = 'block'
         if ('left' in self.refWidget.style) and ('top' in self.refWidget.style) and ('height' in self.refWidget.style) and ('width' in self.refWidget.style) and ('height' in self.style) and ('width' in self.style):
             self.style['left'] = gui.to_pix(gui.from_pix(self.refWidget.style['width'])+gui.from_pix(self.refWidget.style['left'])-gui.from_pix(self.style['width'])/2)
             self.style['top'] = gui.to_pix(gui.from_pix(self.refWidget.style['height'])+gui.from_pix(self.refWidget.style['top'])-gui.from_pix(self.style['height'])/2)
     except:
         self.style['display'] = 'none'
Exemplo n.º 20
0
    def construct_tabview(self):
        # make tab bar as wide as the frame
        if self.bar_width < self.frame_width:
            blank_width = self.frame_width - self.bar_width
            but = gui.Button('', width=blank_width, height=self.bar_height)
            self.tab_bar.append(but, key='xxblank')
            self.bar_width = self.frame_width

        self.tab_bar.style['width'] = gui.to_pix(self.bar_width)
        self.tab_title = gui.Label('fred',
                                   width=self.frame_width - 30,
                                   height=20)
        self.tab_title.style['margin'] = '2px'

        # frame for the tab panel, different tabs are switched into this frame.
        self.tab_frame = gui.Container(width=self.frame_width,
                                       height=self.frame_height)  #0
        self.tab_frame.set_layout_orientation(gui.Container.LAYOUT_VERTICAL)

        # add the bar, panels and title to the subclassed Widget
        self.append(self.tab_bar, key='tab_bar')
        self.append(self.tab_title, key='tab_title')
        self.append(self.tab_frame, key='tab_frame')
        self.set_size(self.bar_width, self.frame_height + 100)
        return self
Exemplo n.º 21
0
 def on_dropped(self, left, top):
     try:
         if ('left' in self.refWidget.style) and (
                 'top' in self.refWidget.style
         ) and ('height' in self.refWidget.style) and (
                 'width' in self.refWidget.style) and (
                     'height' in self.style) and ('width' in self.style):
             self.refWidget.style['width'] = gui.to_pix(
                 gui.from_pix(self.refWidget.style['width']) +
                 gui.from_pix(left) - gui.from_pix(self.style['left']))
             self.refWidget.style['height'] = gui.to_pix(
                 gui.from_pix(self.refWidget.style['height']) +
                 gui.from_pix(top) - gui.from_pix(self.style['top']))
     except:
         pass
     self.update_position()
Exemplo n.º 22
0
 def move_widget(self, css_key, value):
     # css_key can be 'top' or 'left'
     # value (int): positive or negative value
     if issubclass(self.selectedWidget.__class__,
                   gui.Widget) and css_key in self.selectedWidget.style:
         self.selectedWidget.style[css_key] = gui.to_pix(
             gui.from_pix(self.selectedWidget.style[css_key]) + value)
Exemplo n.º 23
0
Arquivo: editor.py Projeto: CSCG/remi
 def update_position(self):
     if self.refWidget == None:
         return
     if self.refWidget.style['position'] != 'absolute':
         self.style['display'] = 'none'
         return
     self.style['position'] = 'absolute'
     self.style['display'] = 'block'
     self.style['left'] = gui.to_pix(
         gui.from_pix(self.refWidget.style['width']) +
         gui.from_pix(self.refWidget.style['left']) -
         gui.from_pix(self.style['width']) / 2)
     self.style['top'] = gui.to_pix(
         gui.from_pix(self.refWidget.style['height']) +
         gui.from_pix(self.refWidget.style['top']) -
         gui.from_pix(self.style['height']) / 2)
Exemplo n.º 24
0
 def on_drag(self, emitter, x, y):
     if self.active:
         if self.origin_x == -1:
             self.origin_x = int(x)
             self.origin_y = int(y)
             self.refWidget_origin_w = gui.from_pix(
                 self.refWidget.style['width'])
             self.refWidget_origin_h = gui.from_pix(
                 self.refWidget.style['height'])
         else:
             self.refWidget.style['width'] = gui.to_pix(
                 self.refWidget_origin_w + int(x) - self.origin_x)
             self.refWidget.style['height'] = gui.to_pix(
                 self.refWidget_origin_h + int(y) - self.origin_y)
             self.update_position()
         return self.eventManager.propagate(self.EVENT_ONDRAG, ())
Exemplo n.º 25
0
    def __init__(self, x_pos, y_pos, wide, high, *args, **kwargs):
        """ x_pos and y_pos are coordinates indicated by the pointer, generally at the center of the shown tape
        """
        gui.SvgGroup.__init__(self, *args, **kwargs)

        self.wide = wide
        self.high = high

        self.attributes['transform'] = 'translate(%s %s)' % (x_pos, y_pos)

        #it is used a subcontainer in order to show only a part of the entire tape
        self.subcontainer = gui.SvgSubcontainer(-self.wide, -self.high / 2,
                                                wide, high)
        self.subcontainer.set_viewbox(-self.wide / 2, -self.high / 2, wide,
                                      self.high)
        self.append(self.subcontainer)

        vertical_line_width = self.wide / 20
        scale_vertical_line = gui.SvgLine(-self.wide / 2, -self.high / 2,
                                          -self.wide / 2, self.high)
        scale_vertical_line.set_stroke(vertical_line_width, 'lightgray')
        self.subcontainer.append(scale_vertical_line)

        self.pointer_line = gui.SvgLine(self.wide / 2, 0, -self.wide / 2,
                                        self.value * (self.high / 2))
        self.pointer_line.set_stroke(self.wide / 14, 'lightgray')
        self.subcontainer.append(self.pointer_line)

        self.value_max = gui.SvgText(-self.wide / 2 + vertical_line_width,
                                     -self.high / 2, "10")
        self.value_max.attr_dominant_baseline = 'hanging'
        self.value_max.attr_text_anchor = 'start'
        self.value_max.set_fill('white')
        self.value_max.css_font_size = gui.to_pix(0.3 * self.wide)
        self.value_max.css_font_weight = 'bolder'
        #self.value_max.attributes['transform'] = 'translate(0 %s)'%(self.vh/2-0.11*self.vh)
        self.subcontainer.append(self.value_max)

        self.value_min = gui.SvgText(-self.wide / 2 + vertical_line_width,
                                     self.high / 2, "-10")
        self.value_min.attr_dominant_baseline = 'ideographic'
        self.value_min.attr_text_anchor = 'start'
        self.value_min.set_fill('white')
        self.value_min.css_font_size = gui.to_pix(0.3 * self.wide)
        self.value_min.css_font_weight = 'bolder'
        #self.value_min.attributes['transform'] = 'translate(0 %s)'%(self.vh/2-0.11*self.vh)
        self.subcontainer.append(self.value_min)
Exemplo n.º 26
0
    def build_scale(self):
        #self.group_scale.empty()

        #horizontal line along all the tape size
        x = self.wide / 2 if self.left_side else -self.wide / 2
        line = gui.SvgLine(x, -self.value - self.scale_length_visible / 2, x,
                           -self.value + self.scale_length_visible / 2)
        line.set_stroke(0.1 * self.wide, 'gray')
        self.group_scale.append(line, "line")

        #creating labels
        labels = {}
        labels_size = {}
        step = 10
        for i in range(
                int(self.value / step - 1 -
                    (self.scale_length_visible / step) / 2),
                int(self.value / step +
                    (self.scale_length_visible / step) / 2 + 1)):
            if not i * step in labels.keys() and i * step >= 0:
                labels[i * step] = "%d" % (i * step)
                labels_size[i * step] = 1.0

        indicator_x = (self.wide / 2 -
                       self.indicator_size) if self.left_side else (
                           -self.wide / 2 + self.indicator_size)
        text_x = ((self.wide / 2 - self.indicator_size) if self.left_side else
                  (self.wide / 2 - 0.05 * self.wide))
        content = ""
        for v in range(int(self.value - self.scale_length_visible / 2),
                       int(self.value + self.scale_length_visible / 2 + 1)):
            if v in labels.keys():
                y = -v
                """line = gui.SvgLine(indicator_x, y, self.wide/2 if self.left_side else -self.wide/2, y)
                line.set_stroke(0.03*self.wide, 'gray')
                self.group_scale.append(line)
                """
                content += """<line class="SvgLine" x1="%(x1)s" y1="%(y1)s" x2="%(x2)s" y2="%(y2)s" stroke="gray" stroke-width="0.6"></line>""" % {
                    'x1': indicator_x,
                    'y1': y,
                    'x2':
                    (self.wide / 2 if self.left_side else -self.wide / 2),
                    'y2': y
                }

                content += """<text class="SvgText" x="%(x)s" y="%(y)s" fill="white" style="dominant-baseline:middle;text-anchor:end;font-size:%(font)s;font-weight:bolder">%(text)s</text>""" % {
                    'x': text_x,
                    'y': y,
                    'text': labels.get(v, ''),
                    'font': gui.to_pix(0.28 * self.wide)
                }
                """txt = gui.SvgText(text_x, y, labels.get(v, ''))
                txt.attr_dominant_baseline = 'middle'
                txt.attr_text_anchor = 'end' if self.left_side else 'end'
                txt.set_fill('white')
                txt.css_font_size = gui.to_pix(0.25*self.wide*labels_size[v])
                txt.css_font_weight = 'bolder'
                self.group_scale.append(txt)"""
        self.group_scale.add_child('content', content)
Exemplo n.º 27
0
 def __init__(self, **kwargs):
     super(MaterialIcon, self).__init__(**kwargs)
     self.type = 'i'
     self.style['font-size'] = 'small'
     self.style['padding'] = gui.to_pix(4)
     if animate:
         self.add_class('material-icons w3-animate-zoom')
     else:
         self.add_class('material-icons')
Exemplo n.º 28
0
                    def __init__(self, **kwargs):
                        super(item, self).__init__(**kwargs)

                        self.style['font-size'] = config[
                            'font-size-dropbox-item']
                        self.style['padding'] = gui.to_pix(
                            int(config['dropbox-item-padding']))
                        self.add_class('w3-bar-item w3-button w3-animate-left')
                        self.onclick.do(event)
Exemplo n.º 29
0
    def panel_logic(self):
        self.properties_label = gui.Label(text="Properties Panel")
        self.properties_label.set_identifier('DragWidgetEditorPanelheader')
        self.properties_label.style['color'] = config["primary-foreground-color"]
        self.properties_label.style['display'] = 'table-row'
        self.properties_label.style['position'] = 'relative'
        self.properties_label.style['cursor'] = 'move'
        
        self.panel.append(self.properties_label)

        self.properties_list_canvas = gui.Widget()
        self.properties_list_canvas.style['overflow-y'] = 'scroll'
        self.properties_list_canvas.style['overflow-x'] = 'scroll'
        self.properties_list_canvas.style['position'] = 'relative'
        self.properties_list_canvas.style['width'] = '100%'
        self.properties_list_canvas.style['display'] = 'table-row'
        self.properties_list_canvas.style['height'] = '250px'
        self.properties_list_canvas.style['background-color'] = config["panel-background-color"]
        self.panel.append(self.properties_list_canvas)

        self.properties_label = gui.Label(text="Project Panel")
        self.properties_label.style['color'] = config["primary-foreground-color"]
        self.properties_label.style['display'] = 'table-row'
        self.properties_label.style['position'] = 'relative'
        self.panel.append(self.properties_label)

        self.project_list_canvas = gui.Widget()
        self.project_list_canvas.style['display'] = 'table-row'
        self.project_list_canvas.style['overflow-y'] = 'scroll'
        self.project_list_canvas.style['overflow-x'] = 'scroll'
        self.project_list_canvas.style['position'] = 'fixed'
        self.project_list_canvas.style['height'] = '40%'
        self.project_list_canvas.style['width'] = str(gui.to_pix(int(config["panel-width"]) - 10))
        self.project_list_canvas.style['bottom'] = '22px'
        self.project_list_canvas.style['background-color'] = config["panel-background-color"]
        self.panel.append(self.project_list_canvas)

        time.sleep(0.5)
        self.panel.style['width'] = gui.to_pix(int(config["panel-width"]))
        self.panel.add_class('w3-animate-right')
Exemplo n.º 30
0
    def append_poly(self, poly):
        self.append(poly)
        self.polyList.append(poly)
        poly.textXMin = gui.SvgText(0, 0, "actualValue")
        poly.textXMax = gui.SvgText(0, 0, "actualValue")
        poly.textYVal = gui.SvgText(0, 0, "actualValue")
        poly.textYVal.style['font-size'] = gui.to_pix(self.font_size)

        poly.lineYValIndicator = gui.SvgLine(0, 0, 0, 0)
        poly.lineXMinIndicator = gui.SvgLine(0, 0, 0, 0)
        poly.lineXMaxIndicator = gui.SvgLine(0, 0, 0, 0)
        self.append([poly.textXMin, poly.textXMax, poly.textYVal, poly.lineYValIndicator, 
            poly.lineXMinIndicator, poly.lineXMaxIndicator])
Exemplo n.º 31
0
    def append_poly(self, polys):
        for poly in polys:
            self.append(poly)
            self.polyList.append(poly)
            poly.textXMin = gui.SvgText(0, 0, "actualValue")
            poly.textXMax = gui.SvgText(0, 0, "actualValue")
            poly.textYVal = gui.SvgText(0, 0, "actualValue")
            poly.textYVal.style['font-size'] = gui.to_pix(self.font_size)

            poly.lineYValIndicator = gui.SvgLine(0, 0, 0, 0)
            poly.lineXMinIndicator = gui.SvgLine(0, 0, 0, 0)
            poly.lineXMaxIndicator = gui.SvgLine(0, 0, 0, 0)
            self.append([poly.textXMin, poly.textXMax, poly.textYVal, poly.lineYValIndicator, 
                poly.lineXMinIndicator, poly.lineXMaxIndicator])
Exemplo n.º 32
0
    def onclick_bt_set_logo(self, emitter):
        x = gui.from_pix(self.selection_area_widget.style['left'])
        y = gui.from_pix(self.selection_area_widget.style['top'])
        w = gui.from_pix(self.selection_area_widget.style['width'])
        h = gui.from_pix(self.selection_area_widget.style['height'])

        self.roi_logo_widget.style['left'] = self.selection_area_widget.style['left']
        self.roi_logo_widget.style['top'] = "1px" #self.selection_area_widget.style['top']
        self.roi_logo_widget.style['width'] = self.selection_area_widget.style['width']
        self.roi_logo_widget.style['height'] = gui.to_pix(self.camera_image.img.shape[0])#self.selection_area_widget.style['height']

        img = self.camera_image.img[y:y+h, x:x+w]
        self.logo_image = img
        self.save_image_add_miniature(img, "logo.png")
Exemplo n.º 33
0
            def __init__(self, **kwargs):
                super(toolbar, self).__init__(**kwargs)

                self.style['width'] = '100%'
                self.style['top'] = str(15)
                self.style['height'] = gui.to_pix(30)
                self.style['position'] = 'fixed'
                self.style['background-color'] = config["tool-background-color"]

                class place_holder_text(toolUI.ToolUI):
                    def __init__(self, **kwargs):
                        super(place_holder_text, self).__init__(**kwargs)
                        pass
                
                self.append(place_holder_text(text='Toolbar'))
Exemplo n.º 34
0
    def __init__(self, self_pointer, **kwargs):
        super(SchematicEditor, self).__init__(**kwargs)
        self_pointer.canvas.empty()

        def add_component_button_event(event):
            return ComponentImporter(self_pointer=self_pointer)

        add_component_button = EditorActionBarButton(text='add')
        add_component_button.onclick.do(add_component_button_event)
        self_pointer.actionbar.append(add_component_button)

        component_widget = gui.Widget()
        component_widget.set_identifier('DragWidgetEditorProperty')
        component_widget.style['width'] = gui.to_pix(40)
        component_widget.style['height'] = gui.to_pix(40)
        component_widget.style['position'] = 'absolute'

        inside = gui.Label(text='Hi')
        inside.style['background-color'] = '#2196F3'
        inside.style['cursor'] = 'move'
        inside.set_identifier(component_widget.identifier + 'header')
        component_widget.append(inside)

        self_pointer.canvas.append(component_widget)
Exemplo n.º 35
0
    def deploy_component(self, self_pointer, text):
        self_pointer.canvas.empty()
        component_widget = gui.Widget()

        def inject_drag_property_to_widget_thread():
            while True:
                time.sleep(1)
                print(dir(component_widget))
                inject_drag_property_to_widget(self_pointer,
                                               component_widget.identifier)

        threading.Thread(target=inject_drag_property_to_widget_thread,
                         args=()).start()
        component_widget.style['width'] = gui.to_pix(40)
        component_widget.style['height'] = gui.to_pix(40)
        component_widget.style['position'] = 'absolute'

        inside = gui.Label(text=text)
        inside.style['background-color'] = '#2196F3'
        inside.style['cursor'] = 'move'
        inside.set_identifier(component_widget.identifier + 'header')
        component_widget.append(inside)

        self_pointer.canvas.append(component_widget)
Exemplo n.º 36
0
    def __init__(self, icon, **kwargs):
        super(EditorButton, self).__init__(**kwargs)
        self.type = 'a'
        self.style['font-family'] = 'Roboto'
        self.style['border-radius'] = gui.to_pix(4)
        self.style['background-color'] = config["button-background-color"]
        self.style['color'] = config["primary-foreground-color"]
        self.add_class('bounceIn w3-button')

        class MaterialIcon(gui.Label):
            def __init__(self, **kwargs):
                super(MaterialIcon, self).__init__(**kwargs)
                self.type = 'i'
                self.style['font-size'] = 'small'
                self.style['padding'] = gui.to_pix(4)
                self.add_class('material-icons')

        self.append(MaterialIcon(text=icon))
Exemplo n.º 37
0
 def construct_tabview(self):
     # make tab bar as wide as the frame
     if self.bar_width<self.frame_width:
         blank_width=self.frame_width-self.bar_width
         but=gui.Button('',width=blank_width,height=self.bar_height)
         self.tab_bar.append(but,key='xxblank')
         self.bar_width=self.frame_width
         
     self.tab_bar.style['width']=gui.to_pix(self.bar_width)
     self.tab_title=gui.Label('fred',width=self.frame_width-30,height=20)
     self.tab_title.style['margin']='2px'
     
     # frame for the tab panel, different tabs are switched into this frame.
     self.tab_frame=gui.Widget(width=self.frame_width,height=self.frame_height) #0
     self.tab_frame.set_layout_orientation(gui.Widget.LAYOUT_VERTICAL)
     
     # add the bar, panels and title to the subclassed Widget
     self.append(self.tab_bar,key='tab_bar')
     self.append(self.tab_title,key='tab_title')
     self.append(self.tab_frame,key='tab_frame')
     self.set_size(self.bar_width,self.frame_height + 100)
     return self
Exemplo n.º 38
0
    def __init__(self, title, field_content, record_specs,field_specs,show_refs,initial_media_dir,
                        pp_home_dir,initial_tab,callback):

        self.callback=callback
        self.frame_width=450
        self.frame_height=400
        self.field_width= 250
        self.ffn_width=400
        self.ffn_height=300

        super(WebEditItem, self).__init__('<b>'+title+'</b>','',width=self.ffn_width+700,height=600,autohide_ok=False)

        self.field_content = field_content   # dictionary - the track parameters to be edited and returned
                                                                 # key is field name e.g. omx-window
        self.record_specs= record_specs  # list of field names and seps/tabs in the order that they appear
        self.field_specs=field_specs          # dictionary of specs referenced by field name
        
        self.show_refs=show_refs            # used for droppdown of list of shows
        self.show_refs.append('')
        
        self.initial_media_dir=initial_media_dir
        self.pp_home_dir=pp_home_dir
        self.initial_tab=initial_tab

        # Create a File Folder Navigator in a frame
        self.ffn = gui.FileFolderNavigator(False,self.initial_media_dir,True,False)#width=self.ffn_width, height=self.ffn_height

        # with some buttons
        self.ffn_select=gui.Button('Select',width=100,height=30)
        self.ffn_cancel=gui.Button('Cancel',width=100,height=30)
        self.ffn_select.set_on_click_listener(self,'on_fileselection_dialog_select')
        self.ffn_cancel.set_on_click_listener(self,'on_fileselection_dialog_cancel')
        self.ffn_button_frame=gui.HBox(width=self.ffn_width+60,height=30)
        self.ffn_button_frame.append(self.ffn_cancel)
        self.ffn_button_frame.append(self.ffn_select)

        # and error label for ffn
        self.ffn_error=gui.Label('',width=self.ffn_width,height=20)

        # frame for ffn and buttons
        self.ffn_frame=gui.VBox(width=self.ffn_width+60, height=self.ffn_height+90) #10
        self.ffn_frame.append(self.ffn,key='ffn')
        self.ffn_frame.append(self.ffn_error,key='ffn_error')
        self.ffn_frame.append(self.ffn_button_frame,key='ffn_buttons')

  

        # create a Tabbed Editor
        self.tabview= TabView(self.frame_width,self.frame_height,30)


        # tabs are created dynamically from pp_definitions.py
        # get fields for this record using the record type in the loaded record
        record_fields=self.record_specs[self.field_content['type']]

        # init results of building the form
        self.tab_row=1 # row on form
        self.field_objs=[]  # list of field objects in record fields order, not for sep or tab
        self.field_index=0 # index to self.field_objs incremented after each field except tab and sep
                                        # can be used as an index to self.field_objs and self.button_objs
        self.button_objs=[]   # list of button objects in record field order , not for sep or tab =None for non-buttons
        
        # populate the dialog box using the record fields to determine the order
        for field in record_fields:
            # get list of values where required
            values=[]
            if self.field_specs[field]['shape']in("option-menu",'spinbox'):
                # print 'should be field name', field
                # print 'should be shape',self.field_specs[field]['shape']
                if field in ('sub-show','start-show'):
                    values=self.show_refs                    
                else:
                    values=self.field_specs[field]['values']
            else:
                values=[]
            # make the entry
            obj,button=self.make_entry(field,self.field_specs[field],values)
            if obj is not  None:
                self.field_objs.append(obj)
                self.button_objs.append(button)
                self.field_index +=1

        #construct the tabview
        self.tabview.construct_tabview()
        
        # frame for file navigator and tabbed editor
        # conent of frame is switched between ffn and tabview
        self.root = gui.HBox(width=self.tabview.get_width() + 100, height=self.frame_height+ 100) #1
        self.root.append(self.tabview,key='switch')
        self.add_field('cont',self.root)

        #adjust width of diaolg box
        self.style['width']=gui.to_pix(self.tabview.get_width() + 200)
        
        self.set_on_confirm_dialog_listener(self,'confirm')      
        return None
Exemplo n.º 39
0
    def __init__(self, width, height, _min, _max):
        super(Gauge, self).__init__(width, height)
        self.width = width
        self.height = height
        self.min = _min
        self.max = _max
        self.scale_angle_range = math.pi * 2 - 1.0
        self.scale_value_range = _max - _min
        self.base_angle = 0  #-self.scale_angle_range/2.0

        self.radius = min(width, height) / 2.0
        circle = gui.SvgCircle(width / 2.0, height / 2.0, self.radius)
        self.append(circle)
        circle.set_fill('gray')
        circle.set_stroke(1, 'lightgray')

        circle = gui.SvgCircle(width / 2.0, height / 2.0,
                               self.radius * 92.0 / 100.0)
        self.append(circle)
        circle.set_fill('lightgray')
        circle.set_stroke(1, 'lightgray')

        font_size = self.radius * 10.0 / 100.0
        xy = self.value_to_xy_tuple(_min, self.radius * 90.0 / 100.0)
        textMin = gui.SvgText(xy[0], xy[1], str(_min))
        xy = self.value_to_xy_tuple(_max, self.radius * 90.0 / 100.0)
        textMax = gui.SvgText(xy[0], xy[1], str(_max))
        textMin.style['font-size'] = gui.to_pix(font_size)
        textMax.style['font-size'] = gui.to_pix(font_size)
        textMin.style['text-anchor'] = "end"
        textMax.style['text-anchor'] = "end"
        textMin.set_fill('red')
        textMax.set_fill('green')

        for i in range(0, 11):
            xy1 = self.value_to_xy_tuple(
                self.min + self.scale_value_range / 10 * i,
                self.radius * 92.0 / 100.0)
            xy2 = self.value_to_xy_tuple(
                self.min + self.scale_value_range / 10 * i, self.radius)
            tick = gui.SvgLine(xy1[0], xy1[1], xy2[0], xy2[1])
            tick.set_stroke(2, 'white')
            self.append(tick)

        self.append(textMin)
        self.append(textMax)

        self.arrow = gui.SvgPolyline()
        self.arrow.add_coord(-self.radius * 20.0 / 100.0, 0)
        self.arrow.add_coord(-self.radius * 23.0 / 100.0,
                             self.radius * 10.0 / 100.0)
        self.arrow.add_coord(0, 0)
        self.arrow.add_coord(-self.radius * 23.0 / 100.0,
                             -self.radius * 10.0 / 100.0)
        self.arrow.add_coord(-self.radius * 20.0 / 100.0, 0)
        self.arrow.style['fill'] = 'white'
        self.arrow.set_stroke(1.0, 'white')
        self.append(self.arrow)

        self.arrow_preview = gui.SvgPolyline()
        self.arrow_preview.add_coord(-self.radius * 10.0 / 100.0, 0)
        self.arrow_preview.add_coord(-self.radius * 13.0 / 100.0,
                                     self.radius * 5.0 / 100.0)
        self.arrow_preview.add_coord(0, 0)
        self.arrow_preview.add_coord(-self.radius * 13.0 / 100.0,
                                     -self.radius * 5.0 / 100.0)
        self.arrow_preview.add_coord(-self.radius * 10.0 / 100.0, 0)
        self.arrow_preview.style['fill'] = 'beige'
        self.arrow_preview.set_stroke(1.0, 'beige')
        self.append(self.arrow_preview)

        self.set_value(_min)
Exemplo n.º 40
0
 def update_position(self):
     self.style['position']='absolute'
     self.style['left']=gui.to_pix(gui.from_pix(self.refWidget.style['left']) + gui.from_pix(self.refWidget.style['width']) - gui.from_pix(self.style['width'])/2)
     self.style['top']=gui.to_pix(gui.from_pix(self.refWidget.style['top']) + gui.from_pix(self.refWidget.style['height']) - gui.from_pix(self.style['height'])/2)
Exemplo n.º 41
0
    def __init__(self, title, field_content, record_specs,field_specs,show_refs,initial_media_dir,
                        pp_home_dir,pp_profile_dir,initial_tab,callback):

        self.callback=callback
        self.frame_width=800   # frame for 2 columns
        self.col_width=400     # width of a column
        self.field_width= 200  # width of data field, label must fit in col_width-field_width- 15
        self.fields_height=300
        self.rows_in_col=15
        self.tab_height=100
        self.okcancel_height=100


        super(WebEditItem, self).__init__('<b>'+title+'</b>','',width=self.frame_width+700,height=self.fields_height+self.tab_height+self.okcancel_height,
                                          confirm_name='OK',cancel_name='Cancel')

        self.field_content = field_content   # dictionary - the track parameters to be edited and returned
                                                                 # key is field name e.g. omx-window
        self.record_specs= record_specs  # list of field names and seps/tabs in the order that they appear
        self.field_specs=field_specs          # dictionary of specs referenced by field name
        
        self.show_refs=show_refs            # used for droppdown of list of shows
        self.show_refs.append('')
        
        self.initial_media_dir=initial_media_dir
        self.pp_home_dir=pp_home_dir
        self.pp_profile_dir=pp_profile_dir
        self.initial_tab=initial_tab


        # create a Tabbed Editor
        self.tabview= TabView(self.frame_width,self.fields_height,30)


        # tabs are created dynamically from pp_definitions.py
        # get fields for this record using the record type in the loaded record
        record_fields=self.record_specs[self.field_content['type']]

        # init results of building the form
        self.tab_row=1 # row on form
        self.field_objs=[]  # list of field objects in record fields order, not for sep or tab
        self.field_index=0 # index to self.field_objs incremented after each field except tab and sep
                                        # can be used as an index to self.field_objs and self.button_objs
        self.button_objs=[]   # list of button objects in record field order , not for sep or tab =None for non-buttons
        
        self.col_row=0
        self.current_col=None
        self.col_1=None
        # populate the dialog box using the record fields to determine the order
        for field in record_fields:
            # get list of values where required
            values=[]
            if self.field_specs[field]['shape']in("option-menu",'spinbox'):
                # print 'should be field name', field
                # print 'should be shape',self.field_specs[field]['shape']
                if field in ('sub-show','start-show'):
                    values=self.show_refs                    
                else:
                    values=self.field_specs[field]['values']
            else:
                values=[]
            # make the entry
            obj,button=self.make_entry(field,self.field_specs[field],values)
            if obj is not  None:
                self.field_objs.append(obj)
                self.button_objs.append(button)
                self.field_index +=1

        #construct the tabview
        self.tabview.construct_tabview()
        
        # frame for tabbed editor
        self.root_frame = gui.HBox(width=self.tabview.get_width() + 100, height=self.fields_height+self.tab_height) #1
        self.root_frame.append(self.tabview,key='switch')
        self.append_field(self.root_frame,'cont')

        #adjust width of dialog box
        self.style['width']=gui.to_pix(self.tabview.get_width() + 100)
         
        return None
Exemplo n.º 42
0
    def __init__(self, width, height, _min, _max):
        super(Gauge, self).__init__(width, height)
        self.width = width
        self.height = height
        self.min = _min
        self.max = _max
        self.scale_angle_range = math.pi*2-1.0
        self.scale_value_range = _max - _min
        self.base_angle = 0 #-self.scale_angle_range/2.0

        self.radius = min(width, height)/2.0
        circle = gui.SvgCircle(width/2.0, height/2.0, self.radius)
        self.append(circle)
        circle.set_fill('gray')
        circle.set_stroke(1,'lightgray')

        circle = gui.SvgCircle(width/2.0, height/2.0, self.radius*92.0/100.0)
        self.append(circle)
        circle.set_fill('lightgray')
        circle.set_stroke(1,'lightgray')

        font_size = self.radius*10.0/100.0
        xy = self.value_to_xy_tuple(_min, self.radius*90.0/100.0)
        textMin = gui.SvgText(xy[0], xy[1], str(_min))
        xy = self.value_to_xy_tuple(_max, self.radius*90.0/100.0)
        textMax = gui.SvgText(xy[0], xy[1], str(_max))
        textMin.style['font-size'] = gui.to_pix(font_size)
        textMax.style['font-size'] = gui.to_pix(font_size)
        textMin.style['text-anchor'] = "end"
        textMax.style['text-anchor'] = "end"
        textMin.set_fill('red')
        textMax.set_fill('green')

        for i in range( 0, 11 ):
            xy1 = self.value_to_xy_tuple(self.min + self.scale_value_range/10*i, self.radius*92.0/100.0)
            xy2 = self.value_to_xy_tuple(self.min + self.scale_value_range/10*i, self.radius)
            tick = gui.SvgLine(xy1[0], xy1[1], xy2[0], xy2[1])
            tick.set_stroke(2, 'white')
            self.append(tick)

        self.append(textMin)
        self.append(textMax)
    
        self.arrow = gui.SvgPolyline()
        self.arrow.add_coord(-self.radius*20.0/100.0,0)
        self.arrow.add_coord(-self.radius*23.0/100.0,self.radius*10.0/100.0)
        self.arrow.add_coord(0,0)
        self.arrow.add_coord(-self.radius*23.0/100.0,-self.radius*10.0/100.0)
        self.arrow.add_coord(-self.radius*20.0/100.0,0)
        self.arrow.style['fill'] = 'white'
        self.arrow.set_stroke(1.0, 'white')
        self.append(self.arrow)

        self.arrow_preview = gui.SvgPolyline()
        self.arrow_preview.add_coord(-self.radius*10.0/100.0,0)
        self.arrow_preview.add_coord(-self.radius*13.0/100.0,self.radius*5.0/100.0)
        self.arrow_preview.add_coord(0,0)
        self.arrow_preview.add_coord(-self.radius*13.0/100.0,-self.radius*5.0/100.0)
        self.arrow_preview.add_coord(-self.radius*10.0/100.0,0)
        self.arrow_preview.style['fill'] = 'beige'
        self.arrow_preview.set_stroke(1.0, 'beige')
        self.append(self.arrow_preview)

        self.set_value(_min)
Exemplo n.º 43
0
    def main(self):
        self.color_flipper = ['orange', 'white']

        self.centering_container = gui.Container(width=640,
                                                 height=360,
                                                 style={
                                                     'background-color':
                                                     'black',
                                                     "position": "absolute"
                                                 })

        #to make a left margin or 50px (because of google glasses curvature), I have to calculate a new height
        _w_margin = 40
        _h_margin = 0  # was _w_margin*360/640
        self.main_container = AsciiContainer(width=640 - _w_margin,
                                             height=360 - _h_margin,
                                             style={
                                                 'background-color':
                                                 'transparent',
                                                 'position':
                                                 'relative',
                                                 'margin-left':
                                                 gui.to_pix(_w_margin),
                                                 'margin-top':
                                                 gui.to_pix(_h_margin / 2)
                                             })

        self.main_container.set_from_asciiart("""
        | t0                                                                                                     |
        | left1        | pfd                                                                                     |
        | left1        | pfd                                                                                     |
        | left1        | pfd                                                                                     |
        | left2        | pfd                                                                                     |
        | left2        | pfd                                                                                     |
        | left2        | pfd                                                                                     |
        | left3        | pfd                                                                                     |
        | left3        | pfd                                                                                     |
        | left3        | pfd                                                                                     |
        | left4        | pfd                                                                                     |
        | left4        | pfd                                                                                     |
        | left4        | pfd                                                                                     |
        | s            | m                                   | t5                                 | t6           |
        | t1                                                                                                     |
        """,
                                              gap_horizontal=0,
                                              gap_vertical=0)

        w = "95%"
        h = 30
        self.slider_pitch = gui.SpinBox(0, -90.0, 90.0, 2.0, width=w, height=h)
        self.slider_orientation = gui.SpinBox(0,
                                              -180,
                                              180,
                                              2,
                                              width=w,
                                              height=h)
        self.slider_roll = gui.SpinBox(0, -180, 180, 2.0, width=w, height=h)
        self.slider_altitude = gui.SpinBox(0, 0, 9999, 1.0, width=w, height=h)
        self.slider_speed = gui.SpinBox(0, 0, 999, 1.0, width=w, height=h)
        """
        controls_container = gui.VBox()
        controls_container.append( gui.VBox(children=[gui.Label('pitch'), self.slider_pitch], width=300) )
        controls_container.append( gui.VBox(children=[gui.Label('orientation'), self.slider_orientation], width=300) )
        controls_container.append( gui.VBox(children=[gui.Label('roll'), self.slider_roll], width=300) )
        controls_container.append( gui.VBox(children=[gui.Label('altitude'), self.slider_altitude], width=300) )
        controls_container.append( gui.VBox(children=[gui.Label('speed'), self.slider_speed], width=300) )

        hbox0.append(controls_container)
        """
        h_divisions = 14.0
        self.pfd = PrimaryFlightDisplay(style={'position': 'relative'})
        _style = {
            'text-align': 'center',
            'color': self.standard_label_color,
            'outline': '1px solid black',
            'font-size': '16px'
        }
        self.t0 = gui.Label("T0", style=_style)
        self.t1 = gui.Label("WAITING FOR MAVLINK", style=_style)
        self.t5 = gui.Label("Voltage", style=_style)
        self.t6 = gui.Label("RPM", style=_style)
        self.s = gui.Label("GNSS", style=_style)
        self.m = gui.Label("MODE", style=_style)
        self.left1 = gui.Label("", style=_style)
        self.left2 = gui.Label("", style=_style)
        self.left3 = gui.Label("", style=_style)
        self.left4 = gui.Label("", style=_style)

        self.main_container.append(self.pfd, "pfd")
        self.main_container.append(self.t0, "t0")
        self.main_container.append(self.t1, "t1")
        self.main_container.append(self.t5, "t5")
        self.main_container.append(self.t6, "t6")
        self.main_container.append(self.s, "s")
        self.main_container.append(self.m, "m")
        self.main_container.append(self.left1, "left1")
        self.main_container.append(self.left2, "left2")
        self.main_container.append(self.left3, "left3")
        self.main_container.append(self.left4, "left4")

        # Here I start a parallel thread
        self.thread_alive_flag = True
        t = threading.Thread(target=self.my_threaded_function)
        t.start()

        self.centering_container.append(self.main_container)
        return self.centering_container
Exemplo n.º 44
0
    def __init__(self, *args, **kwargs):

        gui.SvgSubcontainer.__init__(self, -self.vw / 2, -self.vh / 2, self.vw,
                                     self.vh, *args, **kwargs)

        self.attr_viewBox = "%s %s %s %s" % (-self.vw / 2, -self.vh / 2,
                                             self.vw, self.vh)

        self.group_pitch = gui.SvgGroup()
        self.group_pitch.css_transform = "rotate(0deg), translate(0, 0)"
        self.group_pitch.css_transform_box = "fill-box"
        self.group_pitch.css_transform_origin = "center"

        self.group_roll = gui.SvgGroup()
        self.group_roll.css_transform = "rotate(0deg), translate(0, 0)"
        self.group_roll.css_transform_box = "fill-box"
        self.group_roll.css_transform_origin = "50% 20%"
        self.group_roll.append(self.group_pitch)

        #horizon
        #background is static and occupy the entire attidute indicator
        self.horizon_background = gui.SvgRectangle(-self.vw / 2, -self.vh / 2,
                                                   self.vw, self.vh)
        self.horizon_background.set_fill("rgb(0,100,255)")
        self.append(self.horizon_background)

        self.group_horizon_terrain = gui.SvgGroup()
        self.horizon_terrain = gui.SvgRectangle(-self.vw, 0, self.vw * 2,
                                                self.vh * 2)
        self.horizon_terrain.set_fill("rgb(53, 151, 0)")
        self.horizon_terrain.set_stroke(self.vh / 1000.0, "lightgray")
        self.group_horizon_terrain.append(self.horizon_terrain)
        self.append(self.group_horizon_terrain)

        #pitch angle indication
        self.group_pitch_indicator = gui.SvgGroup()
        self.group_pitch.append(self.group_pitch_indicator)
        self.generate_pitch_indicator()

        self.append(self.group_roll)

        #roll angle indication
        min_radius = self.vw * 0.45
        mid_radius = self.vw * 0.48
        max_radius = self.vw * 0.5
        angle_min = -60
        angle_max = 60
        angle_step = 20  # was 5
        for angle in range(angle_min, angle_max + angle_step, angle_step):
            r = min_radius if (angle % 10) == 0 else mid_radius
            x_min = math.cos(math.radians(angle + 90)) * r
            y_min = -math.sin(math.radians(angle + 90)) * r
            x_max = math.cos(math.radians(angle + 90)) * max_radius
            y_max = -math.sin(math.radians(angle + 90)) * max_radius

            hide_scale = abs(int(angle)) > self.pitch_roll_scale_limit

            line = gui.SvgLine(x_min, y_min, x_max, y_max)
            line.set_stroke(self.vw * 0.005,
                            'white' if not hide_scale else 'transparent')
            self.append(line)
            if (angle % 10) == 0:
                x_txt = math.cos(
                    math.radians(angle + 90)) * (min_radius - 0.025 * self.vw)
                y_txt = -math.sin(math.radians(angle + 90)) * (min_radius -
                                                               0.025 * self.vw)
                txt = gui.SvgText(x_txt, y_txt, str(abs(int(angle))))
                txt.attr_dominant_baseline = 'hanging'
                txt.attr_text_anchor = 'middle'
                txt.set_fill('white' if not hide_scale else 'transparent')
                txt.css_font_size = gui.to_pix(self.vw * 0.04)
                txt.css_font_weight = 'bolder'
                self.append(txt)

        self.group_roll_indicator = gui.SvgGroup()
        self.group_roll_indicator.css_visibility = 'visible'
        self.append(self.group_roll_indicator)

        #roll and bank indicator
        self.group_roll_and_bank_angle_indicator = gui.SvgGroup()
        self.roll_indicator = gui.SvgPolygon(3)
        self.roll_indicator.set_fill('red')
        self.roll_indicator.set_stroke(1, 'black')
        self.roll_indicator.add_coord(-0.04 * self.vw, -0.06 * self.vw)
        self.roll_indicator.add_coord(0.0 * self.vw, (-0.06 - 0.03) * self.vw)
        self.roll_indicator.add_coord(0.04 * self.vw, -0.06 * self.vw)
        self.group_roll_and_bank_angle_indicator.append(self.roll_indicator)
        self.bank_indicator = gui.SvgPolygon(4)
        self.bank_indicator.set_fill('transparent')
        self.bank_indicator.set_stroke(1, 'black')
        self.bank_indicator_width = 0.08
        self.bank_indicator.add_coord(
            -(self.bank_indicator_width / 2.0) * self.vw,
            (-0.06 + 0.005) * self.vw)
        self.bank_indicator.add_coord(
            (self.bank_indicator_width / 2.0) * self.vw,
            (-0.06 + 0.005) * self.vw)
        self.bank_indicator.add_coord(
            (self.bank_indicator_width / 2.0) * self.vw,
            (-0.06 + 0.025) * self.vw)
        self.bank_indicator.add_coord(
            -(self.bank_indicator_width / 2.0) * self.vw,
            (-0.06 + 0.025) * self.vw)
        self.group_roll_and_bank_angle_indicator.append(self.bank_indicator)
        self.group_roll_and_bank_angle_indicator.attributes[
            'transform'] = "translate(0 %s)" % (-0.3 * self.vh)
        self.group_roll_indicator.append(
            self.group_roll_and_bank_angle_indicator)

        #airplaine indicator is steady
        thick = 0.02 * self.vw
        self.airplane_svg_left = gui.SvgPolygon(8)
        self.airplane_svg_left.set_fill('gray')
        self.airplane_svg_left.set_stroke(0.005 * self.vw, 'black')
        self.airplane_svg_left.add_coord(-0.2 * self.vw, 0 * self.vw)  #25x8
        self.airplane_svg_left.add_coord(-0.40 * self.vw, 0 * self.vw)
        self.airplane_svg_left.add_coord(-0.40 * self.vw, thick)
        self.airplane_svg_left.add_coord(-0.2 * self.vw - thick, thick)
        self.airplane_svg_left.add_coord(-0.2 * self.vw - thick,
                                         thick + 0.08 * self.vw)
        self.airplane_svg_left.add_coord(-0.2 * self.vw,
                                         thick + 0.08 * self.vw)
        self.airplane_svg_left.add_coord(-0.2 * self.vw, 0.08 * self.vw)

        self.airplane_svg_right = gui.SvgPolygon(8)
        self.airplane_svg_right.set_fill('gray')
        self.airplane_svg_right.set_stroke(0.005 * self.vw, 'black')
        self.airplane_svg_right.add_coord(0.2 * self.vw, 0 * self.vw)  #25x8
        self.airplane_svg_right.add_coord(0.40 * self.vw, 0 * self.vw)
        self.airplane_svg_right.add_coord(0.40 * self.vw, thick)
        self.airplane_svg_right.add_coord(0.2 * self.vw + thick, thick)
        self.airplane_svg_right.add_coord(0.2 * self.vw + thick,
                                          thick + 0.08 * self.vw)
        self.airplane_svg_right.add_coord(0.2 * self.vw,
                                          thick + 0.08 * self.vw)
        self.airplane_svg_right.add_coord(0.2 * self.vw, 0.08 * self.vw)

        self.airplane_svg_center = gui.SvgRectangle(-0.02 * self.vw,
                                                    -0.02 * self.vw,
                                                    0.04 * self.vw,
                                                    0.04 * self.vw)
        self.airplane_svg_center.set_fill('white')
        self.airplane_svg_center.set_stroke(0.005 * self.vw, 'lightgray')

        self.append([
            self.airplane_svg_left, self.airplane_svg_right,
            self.airplane_svg_center
        ])

        #self.generate_orientation_indicator()
        self.orientation_tape = OrientationTapeHorizontal(
            0, 0.4 * self.vh, 0.8 * self.vw, 1.0 * self.vh)
        self.append(self.orientation_tape)

        self.set_skid_slip(0)
Exemplo n.º 45
0
 def update_position(self):
     self.style['position']='absolute'
     if self.refWidget:
         if 'left' in self.refWidget.style and 'top' in self.refWidget.style:
             self.style['left']=gui.to_pix(gui.from_pix(self.refWidget.style['left'])-gui.from_pix(self.style['width']))
             self.style['top']=gui.to_pix(gui.from_pix(self.refWidget.style['top'])-gui.from_pix(self.style['width']))
Exemplo n.º 46
0
 def on_dropped(self, left, top):
     self.optional_style_dict['left'] = gui.to_pix(left)
     self.optional_style_dict['top'] = gui.to_pix(top)
     self.prompt_new_widget()