예제 #1
0
 def draw_plot_gui(self):
     if self.plot_gui:
         imgui.begin("Plot", False)
         imgui.columns(3, 'plot settings', border=True)
         imgui.text('x-axis:')
         for i in range(len(self.x_axis)):
             changed = imgui.radio_button(self.x_axis[i] + '##x', 
                                          i == self.x_axis_index)
             if changed:
                 if self.x_axis_index != i:
                     self.reset_data()
                 self.x_axis_index = i
         imgui.next_column()
         imgui.text('y-axis:')
         for i in range(len(self.y_axis)):
             changed, self.y_axis_on[i] = imgui.checkbox(self.y_axis[i] + '##y', self.y_axis_on[i])
             if changed:
                 self.reset_data()
         imgui.next_column()
         imgui.text('plot:')
         if imgui.button('add'):
             self.add_data()
         if imgui.button('reset'):
             self.reset_data()
         imgui.end()
예제 #2
0
파일: alerts.py 프로젝트: kuzen/ImageViewer
def render_alert(alertItem):
    alert, count = alertItem
    imgui.text(str(count))
    imgui.next_column()
    alert.render()
    imgui.next_column()
    imgui.separator()
예제 #3
0
 def render_row(self, process):
     imgui.begin_group()
     for key in self.attrs:
         imgui.text(str(process.info[key]))
         imgui.next_column()
     imgui.end_group()
     if imgui.is_item_clicked():
         pass
예제 #4
0
def render_alert(alertItem):
    alert, count = alertItem
    if not alert in ignoredAlerts:
        imgui.text(str(count))
        imgui.next_column()
        alert.render()
        imgui.next_column()
        imgui.separator()
예제 #5
0
 def render_header(self, item):
     if item == self.sortKey:
         imgui.text("* "+item)
     else:
         imgui.text(item)
     if imgui.is_item_clicked():
         if item == self.sortKey:
             self.reverseSort = not self.reverseSort
         self.sortKey=item
     imgui.next_column()
예제 #6
0
    def draw(self):
        style = imgui.get_style()

        imgui.begin("Colors")
        imgui.columns(4)
        for color in range(0, imgui.COLOR_COUNT):
            imgui.text("Color: {}".format(color))
            imgui.color_button("color#{}".format(color), *style.colors[color])
            imgui.next_column()

        imgui.end()
예제 #7
0
 def render(self, *args):
     if 'fileInfo' in args[0][0][0]:
         self.info = args[0][0][0]['fileInfo'][0]
     imgui.columns(2, 'info')
     imgui.separator()
     for name in self.info:
         imgui.text(name)
         imgui.next_column()
         imgui.text(self.info[name])
         imgui.next_column()
     imgui.columns(1)
     return {}
예제 #8
0
 def light_props(self):
     expanded, visible = imgui.collapsing_header(
         'Lighting', self.GUI_STATE.lightprop.isvisible)
     style = imgui.get_style()
     if expanded:
         self.SHADER.scene_shader.attach()
         imgui.columns(2, 'GHOST')
         w = imgui.get_window_width()
         imgui.set_column_width(0, w*0.6)
         changed, self.GUI_STATE.lightprop.shininess = imgui.drag_float(
             'Shininess', self.GUI_STATE.lightprop.shininess, self.props.steps, 0.001, 30.0)
         if changed:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'shininess', self.GUI_STATE.lightprop.shininess)
         imgui.next_column()
         imgui.set_column_width(1, w*0.4)
         changed, self.props.steps = imgui.input_float(
             'Step',
             self.props.steps
         )
         imgui.columns(1)
         changed0, self.GUI_STATE.lightprop.specDamp = imgui.drag_float(
             'Specular Damp', self.GUI_STATE.lightprop.specDamp, self.props.steps, 0.001, 30.0)
         if changed0:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'specDamp',
                 self.GUI_STATE.lightprop.specDamp
             )
         changed1, self.GUI_STATE.lightprop.lightcolor = imgui.color_edit3(
             'Light Color', *self.GUI_STATE.lightprop.lightcolor
         )
         self.GUI_STATE.lightprop.lightcolor = Color3(
             *self.GUI_STATE.lightprop.lightcolor)
         if changed1:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'lightColor',
                 self.GUI_STATE.lightprop.lightcolor
             )
         if imgui.radio_button('BLINN', self.props.active):
             self.props.active = not self.props.active
         if self.props.active:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'blinn',
                 1,
                 dtype='i'
             )
         else:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'blinn',
                 0,
                 dtype='i'
             )
예제 #9
0
def draw_table(data, *selected_row):
    imgui.columns(len(data.columns) + 1, "##table")
    imgui.separator()
    imgui.text("")
    imgui.next_column()
    for c in data.columns:
        imgui.text(c)
        imgui.next_column()
    imgui.separator()
    # fill with data
    i = 0
    for _, row in data.iterrows():
        label = str(i)
        clicked, _ = imgui.selectable(label=label,
                                      selected=selected_row == i,
                                      flags=imgui.SELECTABLE_SPAN_ALL_COLUMNS,
                                      )
        if clicked:
            selected_row = i
        hovered = imgui.is_item_hovered()
        imgui.next_column()
        for c in data.columns:
            imgui.text(row[c])
            imgui.next_column()
        i += 1
예제 #10
0
파일: imgui_env.py 프로젝트: hxrain/scutil
    def on_mod(self, im):
        '''
            进行具体的应用逻辑绘制处理:im为imgui环境对象;返回值告知程序是否继续.
            此方法应该被子类重载,完成具体的功能逻辑
        '''
        # 判断是否有ctrl+Q按下,结束app
        if im.is_key_down('ctrl+Q'):
            return False
        if not self._on_menu():
            return False

        style = imgui.get_style()
        imgui.begin("Color window")
        imgui.columns(4)
        for color in range(0, imgui.COLOR_COUNT):
            imgui.text("Color: {} {}".format(
                color, imgui.get_style_color_name(color)))
            imgui.color_button("color#{}".format(color), *style.colors[color])
            imgui.next_column()
        imgui.end()

        # 获取当前主窗口尺寸
        win_width, win_height = im.main_win.get_size()
        # 定义菜单条高度
        bar_height = 24
        # 计算横向比例分隔
        widths, hpos = split(win_width, (5, 15, 30))
        # 计算左侧竖向比例分隔
        heights, vpos = split(win_height - bar_height, (10, 30))
        # 左侧列表
        self.do_show_text('样本列表', hpos[0], bar_height, widths[0],
                          win_height - bar_height, 'list')
        # 左上窗口
        self.do_show_text('差异处', hpos[1], bar_height + vpos[0], widths[1],
                          heights[0], 'tmp_text')
        # 左下窗口
        self.do_show_text('新结果', hpos[1], bar_height + vpos[1], widths[1],
                          heights[1], '测试123456')
        # 重新计算右侧竖向比例分隔
        heights, vpos = split(win_height - bar_height, (30, 30))
        # 右上窗口
        self.do_show_text('原文本', hpos[2], bar_height + vpos[0], widths[2],
                          heights[0], '测试1234')
        # 右下窗口
        self.do_show_text('预处理', hpos[2], bar_height + vpos[1], widths[2],
                          heights[1], '测试1234')

        #imgui.show_demo_window()
        return True
예제 #11
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        style = imgui.get_style()
        imgui.begin("Colors")
        imgui.columns(4)
        for color in range(0, imgui.COLOR_COUNT):
            imgui.text("Color: {}".format(color))
            imgui.color_button("color#{}".format(color), *style.colors[color])
            imgui.next_column()

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
예제 #12
0
    def render(self, *args):
        imgui.columns(2, 'fileLlist')
        imgui.separator()

        pathlist = os.listdir(os.curdir)
        pathlist.insert(0, os.pardir)
        pathlist.insert(0, os.curdir)
        length = len(pathlist)
        selected = [False] * length
        for i in range(length):
            _, selected[i] = imgui.selectable(pathlist[i], selected[i])
            imgui.next_column()
            size = os.path.getsize(pathlist[i])
            imgui.text(str(size)+' byte')
            imgui.next_column()
            if(selected[i] is True):
                self.path = os.path.abspath(pathlist[i])
                print('clicked ' + pathlist[i])
                if os.path.isdir(self.path):
                    os.chdir(self.path)
                    break

        imgui.next_column()

        imgui.columns(1)
        return {'path': self.path}
예제 #13
0
파일: alerts.py 프로젝트: kuzen/ImageViewer
 def render(self):
     imgui.columns(2, 'alertList')
     imgui.set_column_offset(1, 45)
     imgui.text("Count")
     imgui.next_column()
     imgui.text("Alert")
     imgui.next_column()
     imgui.separator()
     # ToDo: In the future dont revert this, and simple have it lock scroll
     # to bottom like a terminal? Might be more effort than it's worth.
     list(map(render_alert, reversed(alerts.items())))
     imgui.text("Count")
     imgui.next_column()
     imgui.text("Alert")
     imgui.next_column()
     imgui.columns(1)
예제 #14
0
    def draw(self):
        imgui.begin("Example: Columns - File list")
        imgui.columns(4, 'fileList')
        imgui.separator()
        imgui.text("ID")
        imgui.next_column()
        imgui.text("File")
        imgui.next_column()
        imgui.text("Size")
        imgui.next_column()
        imgui.text("Last Modified")
        imgui.next_column()
        imgui.separator()
        imgui.set_column_offset(1, 40)

        imgui.next_column()
        imgui.text('FileA.txt')
        imgui.next_column()
        imgui.text('57 Kb')
        imgui.next_column()
        imgui.text('12th Feb, 2016 12:19:01')
        imgui.next_column()

        imgui.next_column()
        imgui.text('ImageQ.png')
        imgui.next_column()
        imgui.text('349 Kb')
        imgui.next_column()
        imgui.text('1st Mar, 2016 06:38:22')
        imgui.next_column()

        imgui.columns(1)
        imgui.end()
예제 #15
0
def render_plugins_ui(drawing):
    "Draw UI windows for all plugins active for the current drawing."

    # TODO there's an imgui related crash here somewhere preventing (at least) the
    # voxel plugin from being used in more than one drawing. For now: avoid that.

    if not drawing:
        return

    deactivated = set()

    for name, (plugin, sig, args) in drawing.plugins.items():
        _, opened = imgui.begin(f"{name} {id(drawing)}", True)
        if not opened:
            deactivated.add(name)
            imgui.end()
            continue
        imgui.columns(2)
        for param_name, param_sig in islice(sig.items(), 2, None):
            imgui.text(param_name)
            imgui.next_column()
            default_value = args.get(param_name)
            if default_value is not None:
                value = default_value
            else:
                value = param_sig.default
            label = f"##{param_name}_val"
            if param_sig.annotation == int:
                changed, args[param_name] = imgui.drag_int(label, value)
            elif param_sig.annotation == float:
                changed, args[param_name] = imgui.drag_float(label, value)
            elif param_sig.annotation == str:
                changed, args[param_name] = imgui.input_text(label, value, 20)
            elif param_sig.annotation == bool:
                changed, args[param_name] = imgui.checkbox(label, value)
            imgui.next_column()
        imgui.columns(1)

        texture_and_size = getattr(plugin, "texture", None)
        if texture_and_size:
            texture, size = texture_and_size
            w, h = size
            ww, wh = imgui.get_window_size()
            scale = max(1, (ww - 10) // w)
            imgui.image(texture.name,
                        w * scale,
                        h * scale,
                        border_color=(1, 1, 1, 1))

        last_run = getattr(plugin, "last_run", 0)
        period = getattr(plugin, "period", None)
        t = time()
        if period and t > last_run + period or imgui.button("Execute"):
            plugin.last_run = last_run
            try:
                result = plugin(voxpaint, drawing, **args)
                if result:
                    args.update(result)
            except Exception:
                print_exc()

        imgui.button("Help")
        if imgui.begin_popup_context_item("Help", mouse_button=0):
            if plugin.__doc__:
                imgui.text(inspect.cleandoc(plugin.__doc__))
            else:
                imgui.text("No documentation available.")
            imgui.end_popup()
        imgui.end()

    for name in deactivated:
        drawing.plugins.pop(name, None)
예제 #16
0
    def displayInterface(self):

        imgui.begin_child("left_bottom", width=606, height=370)

        if (self.activeInterface == "main"):

            imgui.text("Main Interface (SSH)")
            imgui.begin_child("left_bottom",
                              width=606,
                              height=290,
                              border=True)

            imgui.begin_child("connections", width=606)

            imgui.columns(4, 'ssh_connections')
            imgui.text("ID")
            imgui.next_column()
            imgui.text("USER")
            imgui.next_column()
            imgui.text("IP")
            imgui.next_column()
            imgui.text("Time Connected")
            imgui.separator()

            imgui.set_column_width(0, 70)

            for conn in list(self.activeConnections.keys()):
                now = datetime.now()
                elapsed = now - self.activeConnections[conn]["connected_time"]
                imgui.next_column()
                imgui.text(self.activeConnections[conn]["ssh_proc"])
                imgui.next_column()
                imgui.text(self.activeConnections[conn]["user"])
                imgui.next_column()
                imgui.text(self.activeConnections[conn]["ip"])
                imgui.next_column()
                imgui.text(str(elapsed))

            imgui.columns(1)

            imgui.end_child()
            imgui.end_child()

            imgui.text("Select a SSH Session")

            clicked, current = imgui.combo("##Path input", self.sshSelected,
                                           self.sshSelectionOptions)

            if (clicked):
                self.sshSelected = current

            if (imgui.button("Kick")):
                ssh_proc = self.sshSelectionOptions[
                    self.sshSelected].split()[0][1:-1]
                log.logNorm("Kicked SSH Session (" + ssh_proc + ") " +
                            self.activeConnections[ssh_proc]["user"])
                self.disconnectSSHConnection(ssh_proc)

            imgui.same_line()
            if (imgui.button("Ban Both")):
                self.handleBanningUser()
                self.handleBanningIPAddr()
                self.handleDisconnectingCurrentSelection()

            imgui.same_line()
            if (imgui.button("Ban User")):
                self.handleBanningUser()
                self.handleDisconnectingCurrentSelection()

            imgui.same_line()
            if (imgui.button("Ban IP")):
                self.handleBanningIPAddr()
                self.handleDisconnectingCurrentSelection()

        elif (self.activeInterface == "ban"):
            imgui.text("Ban List (SSH)")
            imgui.begin_child("left_bottom",
                              width=299,
                              height=310,
                              border=True)

            imgui.columns(2, 'ssh_connections')
            imgui.text("USERNAME")
            imgui.next_column()
            imgui.next_column()
            imgui.separator()

            for user in self.banList["users"]:
                imgui.text(user)
                imgui.next_column()

            imgui.columns(1)
            imgui.end_child()

            imgui.same_line()

            imgui.begin_child("right_bottom",
                              width=299,
                              height=310,
                              border=True)
            imgui.text("IP Address")
            imgui.next_column()
            imgui.next_column()
            imgui.separator()

            for user in self.banList["ip_addresses"]:
                imgui.text(user)
                imgui.next_column()

            imgui.columns(1)
            imgui.end_child()

            imgui.begin_child("left_selection", width=299)

            clicked, current = imgui.combo("##Path input",
                                           self.banUserSelected,
                                           self.banList["users"])

            imgui.same_line()

            if (imgui.button("Unban")):
                self.alert("Unbanning User (" +
                           self.banList["users"][self.banUserSelected] + ")")
                del self.banList["users"][self.banUserSelected]
                self.saveBanList()

            imgui.end_child()

            imgui.same_line()

            imgui.begin_child("right_selection", width=299)

            clicked, current = imgui.combo("##Path input", self.banIPSelected,
                                           self.banList["ip_addresses"])

            imgui.same_line()

            if (imgui.button("Unban")):
                self.alert("Unbanning IP (" +
                           self.banList["ip_addresses"][self.banIPSelected] +
                           ")")
                del self.banList["ip_addresses"][self.banIPSelected]
                self.saveBanList()

            imgui.end_child()

        imgui.end_child()

        imgui.same_line()

        imgui.begin_child("ssh_alerts")
        imgui.text("SSH Connections Alerts")

        imgui.begin_child("ssh_alerts_logger", border=True)

        for message in self.alerts:
            imgui.text_wrapped(message)

        imgui.end_child()
        imgui.end_child()
예제 #17
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        imgui.begin("Example: Columns - File list")
        imgui.columns(4, 'fileLlist')
        imgui.separator()
        imgui.text("ID")
        imgui.next_column()
        imgui.text("File")
        imgui.next_column()
        imgui.text("Size")
        imgui.next_column()
        imgui.text("Last Modified")
        imgui.next_column()
        imgui.separator()
        imgui.set_column_offset(1, 40)

        imgui.next_column()
        imgui.text('FileA.txt')
        imgui.next_column()
        imgui.text('57 Kb')
        imgui.next_column()
        imgui.text('12th Feb, 2016 12:19:01')
        imgui.next_column()

        imgui.next_column()
        imgui.text('ImageQ.png')
        imgui.next_column()
        imgui.text('349 Kb')
        imgui.next_column()
        imgui.text('1st Mar, 2016 06:38:22')
        imgui.next_column()

        imgui.columns(1)
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
예제 #18
0
def render_plugins_ui(window):
    "Draw UI windows for all plugins active for the current drawing."
    if not window.drawing:
        return

    drawing = window.drawing

    deactivated = set()
    for name, args in window.drawing.active_plugins.items():
        plugin, sig = window.plugins[name]
        _, opened = imgui.begin(f"{ name } ##{ drawing.path or drawing.uuid }",
                                True)
        if not opened:
            deactivated.add(name)
        imgui.columns(2)
        for param_name, param_sig in islice(sig.items(), 4, None):
            if param_sig.annotation == inspect._empty:
                continue
            imgui.text(param_name)
            imgui.next_column()
            default_value = args.get(param_name)
            if default_value is not None:
                value = default_value
            else:
                value = param_sig.default
            label = f"##{param_name}_val"
            if param_sig.annotation == int:
                changed, args[param_name] = imgui.drag_int(label, value)
            elif param_sig.annotation == float:
                changed, args[param_name] = imgui.drag_float(label, value)
            elif param_sig.annotation == str:
                changed, args[param_name] = imgui.input_text(label, value, 20)
            elif param_sig.annotation == bool:
                changed, args[param_name] = imgui.checkbox(label, value)
            imgui.next_column()
        imgui.columns(1)

        texture_and_size = getattr(plugin, "texture", None)
        if texture_and_size:
            texture, size = texture_and_size
            w, h = size
            ww, wh = imgui.get_window_size()
            scale = max(1, (ww - 10) // w)
            imgui.image(texture.name,
                        w * scale,
                        h * scale,
                        border_color=(1, 1, 1, 1))

        if hasattr(plugin, "ui"):
            result = plugin.ui(oldpaint, imgui, window.drawing, window.brush,
                               **args)
            if result:
                args.update(result)

        last_run = getattr(plugin, "last_run", 0)
        period = getattr(plugin, "period", None)
        t = time()
        # TODO I've seen more readable if-statements in my days...
        if callable(plugin) and ((period and t > last_run + period) or
                                 (not period and imgui.button("Execute"))):
            plugin.last_run = t
            try:
                result = plugin(oldpaint, imgui, window.drawing, window.brush,
                                **args)
                if result:
                    args.update(result)
            except Exception:
                # We don't want crappy plugins to ruin everything
                # Still probably probably possible to crash opengl though...
                logger.error(f"Plugin {name}: {format_exc()}")

        imgui.button("Help")
        if imgui.begin_popup_context_item("Help", mouse_button=0):
            if plugin.__doc__:
                imgui.text(inspect.cleandoc(plugin.__doc__))
            else:
                imgui.text("No documentation available.")
            imgui.end_popup()

        imgui.end()
    for name in deactivated:
        window.drawing.active_plugins.pop(name, None)
예제 #19
0
def interface():
    imgui.new_frame()
    if imgui.begin_main_menu_bar():
        if imgui.begin_menu("File", True):
            clicked_quit, selected_quit = imgui.menu_item(
                "Quit", 'Cmd+Q', False, True)
            if clicked_quit:
                exit(1)
            imgui.end_menu()
        if imgui.begin_menu('Windows', True):
            clicked_fixtureC, selected_fixtureC = imgui.menu_item(
                'Fixture Controls', shortcut=None)
            if clicked_fixtureC:
                if values.showFixtureControl:
                    values.showFixtureControl = False
                else:
                    values.showFixtureControl = True

            imgui.end_menu()
        imgui.end_main_menu_bar()

    if values.showFixtureControl:
        imgui.begin("Fixture Control", True)
        for r in patch.rooms.values():
            expanded, visible = imgui.collapsing_header(r.name)
            if expanded:
                imgui.indent()
                for f in r.fixtureList:
                    expanded, visible = imgui.collapsing_header(f.name)
                    rgb = values.values[f.name]
                    if expanded:
                        imgui.columns(2, f.name)
                        imgui.indent()
                        imgui.text('Red')
                        changed, value = imgui.slider_int(
                            '##int%sred' % f.name, rgb[0], 0, 255)
                        if changed:
                            rgb[0] = value
                            ui.cache(f.setColor, [rgb, 0.2])
                            ui.update()
                        imgui.text('Green')
                        changed, value = imgui.slider_int(
                            '##int%sgreen' % f.name, rgb[1], 0, 255)
                        if changed:
                            rgb[1] = value
                            ui.cache(f.setColor, [rgb, 0.2])
                            ui.update()
                        imgui.text('Blue')
                        changed, value = imgui.slider_int(
                            '##int%sblue' % f.name, rgb[2], 0, 255)
                        if changed:
                            rgb[2] = value
                            ui.cache(f.setColor, [rgb, 0.2])
                            ui.update()
                        imgui.next_column()
                        imgui.color_button('Color Sample',
                                           rgb[0] / 255,
                                           rgb[1] / 255,
                                           rgb[2] / 255,
                                           width=100,
                                           height=100)
                        imgui.columns(1)
                        imgui.unindent()
                imgui.unindent()
        imgui.same_line(spacing=50)
        imgui.end()