コード例 #1
0
ファイル: coloredit4.py プロジェクト: kfields/arcade-imgui
    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: color edit with alpha")

        # note: first element of return two-tuple notifies if the color was changed
        #       in currently processed frame and second element is current value
        #       of color and alpha
        _, self.color = imgui.color_edit4("Alpha",
                                          *self.color,
                                          show_alpha=True)
        _, self.color = imgui.color_edit4("No alpha",
                                          *self.color,
                                          show_alpha=False)

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
コード例 #2
0
ファイル: modes-demo.py プロジェクト: yifan-hou/contact_modes
    def draw_hand_gui(self):
        imgui.begin("Hand", True)

        changed, new_color = imgui.color_edit4('hand', *self.hand_color)
        if changed or self.load_hand:
            self.hand.set_color(np.array(new_color))
            self.hand_color = new_color

        changed, new_color = imgui.color_edit4('baton', *self.baton_color)
        if changed or self.load_hand:
            self.baton.set_color(np.array(new_color))
            self.baton_color = new_color

        imgui.text('state')
        dofs = self.system.get_state()
        for i in range(self.system.num_dofs()):
            changed, value = imgui.slider_float('b%d' % i, dofs[i], -np.pi, np.pi)
            if changed:
                dofs[i] = value
            if i < self.hand.num_dofs():
                imgui.same_line()
                if imgui.button('step###%d'%i):
                    self.close(i)
                    dofs = self.system.get_state()
        self.system.set_state(dofs)
        
        self.load_hand = False
        imgui.end()
コード例 #3
0
ファイル: coloredit.py プロジェクト: kfields/arcade-imgui
    def draw(self):
        imgui.begin("Example: color edit with alpha")

        # note: first element of return two-tuple notifies if the color was changed
        #       in currently processed frame and second element is current value
        #       of color and alpha
        _, self.color = imgui.color_edit4("Alpha",
                                          *self.color,
                                          show_alpha=True)
        _, self.color = imgui.color_edit4("No alpha",
                                          *self.color,
                                          show_alpha=False)

        imgui.end()
コード例 #4
0
    def show_ui(self):
        super().show_ui()

        self.inner_distance = imgui.slider_float(
            f'Start Distance##{self.ui_index}', self.inner_distance, -1.0,
            3.0)[1]
        self.outer_distance = imgui.slider_float(
            f'End Distance##{self.ui_index}', self.outer_distance, -1.0,
            3.0)[1]
        #self.strength = imgui.slider_float(f'Strength##{self.ui_index}', self.strength, 0.0, 2.0)[1]
        #self.scale = imgui.slider_float2(f'Scale##{self.ui_index}', self._scale[0], self._scale[1], 0.0,4.0)[1]

        self.color = imgui.color_edit4(f'Color##{self.ui_index}',
                                       *self.color)[1]
コード例 #5
0
    def draw_scene_gui(self):
        if not self.scene_controls:
            return
        _, opened = imgui.begin("Scene", True)
        if not opened:
            self.scene_controls = False
        
        changed, new_color = imgui.color_edit4('object', *self.object_color)
        if changed or self.load_scene:
            [body.get_shape().set_color(np.array(new_color)) for body in self.system.bodies]
            self.object_color = new_color

        changed, new_color = imgui.color_edit4('obs', *self.obstacle_color)
        if changed or self.load_scene:
            [o.get_shape().set_color(np.array(new_color)) for o in self.system.obstacles]
            self.obstacle_color = new_color

        changed, new_pos = imgui.slider_float3('light', *self.light_pos, -10.0, 10.0)
        if changed or self.load_scene:
            self.light_pos = new_pos

        self.load_scene = True

        imgui.end()
コード例 #6
0
ファイル: MainGUI.py プロジェクト: bertrandboudaud/imagegraph
def display_parameter(parameter, editable):
    global slider_indexes
    if parameter.type == "List":
        if len(parameter.list) == 0:
            imgui.text("Empty list")
        else:
            if parameter.id not in slider_indexes:
                slider_indexes[parameter.id] = 0
            changed, values = imgui.slider_int("index", slider_indexes[parameter.id], 0, len(parameter.list)-1)
            if changed:
                slider_indexes[parameter.id] = values
            display_parameter(parameter.list[slider_indexes[parameter.id]], editable)
    if parameter.type == "Image":
        if parameter.image:
            image_to_texture = get_gl_texture(parameter.image, parameter.timestamp)
            # imgui.image(image_texture, image_width, image_height)
            window_width = 256 # imgui.get_window_width()
            display_width = 0
            display_height = 0
            image_width = image_to_texture.gl_widh
            image_height = image_to_texture.gl_height
            if image_width >= image_height:
                display_width = window_width
                display_height = image_height / (image_width/float(display_width))
            else:
                display_height = window_width
                display_width = image_width / (image_height/float(display_height))
            imgui.image(image_to_texture.gl_texture, display_width, display_height)
            imgui.text("width: " + str(parameter.image.width))
            imgui.text("height: " + str(parameter.image.height))
        else:
            imgui.text("No image available - run workflow or connect an image source")
    elif parameter.type == "Rectangle":
        if editable:
            changed, value = imgui.input_float("Left", parameter.left)
            if changed:
                parameter.left = value
            changed, value = imgui.input_float("Top", parameter.top)
            if changed:
                parameter.top = value
            changed, value = imgui.input_float("Right", parameter.right)
            if changed:
                parameter.right = value
            changed, value = imgui.input_float("Bottom", parameter.bottom)
            if changed:
                parameter.left = value
        else:
            imgui.text("Left: " + str(parameter.left))
            imgui.text("Top: " + str(parameter.top))
            imgui.text("Right: " + str(parameter.right))
            imgui.text("Bottom: " + str(parameter.bottom))
    elif parameter.type == "Coordinates":
        if editable:
            changed, value = imgui.input_float("x", parameter.x)
            if changed:
                parameter.x = value
            changed, value = imgui.input_float("y", parameter.y)
            if changed:
                parameter.y = value
        else:
            imgui.text("x: " + str(parameter.x))
            imgui.text("y: " + str(parameter.y))
    elif parameter.type == "Integer": # to do change to "number"
        if editable:
            changed, value = imgui.input_int("Value", parameter.value)
            if changed:
                parameter.value = value
        else:
            imgui.text("Value: " + str(parameter.value))
    elif parameter.type == "Color":
        changed, color = imgui.color_edit4(parameter.id, parameter.r, parameter.g, parameter.b, parameter.a)
        if editable and changed:
            parameter.r = color[0]
            parameter.g = color[1]
            parameter.b = color[2]
            parameter.a = color[3]
    elif parameter.type == "URL":
        changed, textval = imgui.input_text(parameter.id, parameter.url, 1024)
        if editable and changed:
            parameter.url = textval
        if editable:
            if imgui.button("browse..."):
                root = tk.Tk()
                root.withdraw()
                file_path = filedialog.askopenfilename()
                if file_path:
                    parameter.url = file_path
    elif parameter.type == "Text":
        changed, textval = imgui.input_text(parameter.id, parameter.text, 1024)
        if editable and changed:
            parameter.text = textval
コード例 #7
0
ファイル: Gui.py プロジェクト: skg44444/pyOpenGL
def color_edit(count, label, color):
    if count==4:
        _, color = imgui.color_edit4(label, *color)
        return color
コード例 #8
0
ファイル: modes-demo.py プロジェクト: yifan-hou/contact_modes
    def draw_scene_gui(self):
        imgui.begin("Scene", True)

        imgui.text('test:')

        changed0, self.solver_index = imgui.combo('solver', self.solver_index, 
                                                 self.solver_list)
        
        changed1, self.case_index = imgui.combo('case', self.case_index, 
                                                 self.case_list)

        if changed0 or changed1:
            self.load_scene = True
            new_scene = self.case_list[self.case_index]
            if 'box-case' in new_scene:
                self.build_mode_case(lambda: box_case(int(new_scene[-1])))
            if new_scene == 'peg-in-hole-4':
                self.build_mode_case(lambda: peg_in_hole(4))
            if new_scene == 'peg-in-hole-8':
                self.build_mode_case(lambda: peg_in_hole(8))
            if 'box-box' in new_scene:
                self.build_mode_case(lambda: box_box_case(int(new_scene[-1])))
            if new_scene == 'hand-football':
                self.build_mode_case(lambda: hand_football(False))
            if new_scene == 'hand-football-fixed':
                self.build_mode_case(lambda: hand_football(True))

        imgui.text('control:')
        changed, self.lattice_height = imgui.slider_float('height', self.lattice_height, 0, 500)
        changed, self.plot_gui = imgui.checkbox('plot', self.plot_gui)
        changed, self.max_steps = imgui.drag_float('max steps', self.max_steps,
                                                    1, 0, 200)
        changed, self.h = imgui.drag_float('h', self.h, 0.0001, 0, 0.05)

        imgui.text('render:')
        changed, self.alpha = imgui.slider_float('alpha', self.alpha, 0.0, 1.0)
        if changed or self.load_scene:
            self.renderer.opacity = self.alpha

        changed, self.peel_depth = imgui.slider_int(
            'peel', self.peel_depth, 0, self.renderer.max_peel_depth)
        if changed or self.load_scene:
            self.renderer.peel_depth = self.peel_depth

        changed, new_color = imgui.color_edit4('object', *self.object_color)
        if changed or self.load_scene:
            [body.set_color(np.array(new_color)) for body in self.system.bodies]
            self.object_color = new_color
        
        changed, new_scale = imgui.drag_float3('frame', 
                                               *self.frame_scale,
                                               0.005, 0.0, 5.0)
        if changed or self.load_scene:
            self.frame.set_radius(new_scale[0])
            self.frame.set_length(new_scale[1])
            self.frame.set_alpha(new_scale[2])
            self.frame_scale = new_scale

        changed, new_color = imgui.color_edit4('contact', *self.contact_color)
        if changed or self.load_scene:
            self.contact_spheres[0].set_color(np.array(new_color))
            self.contact_arrows[0].set_color(np.array(new_color))
            self.contact_color = new_color

        changed, new_color = imgui.color_edit4('separate', *self.separating_color)
        if changed or self.load_scene:
            self.contact_spheres[1].set_color(np.array(new_color))
            self.contact_arrows[1].set_color(np.array(new_color))
            self.separating_color = new_color

        changed, new_scale = imgui.drag_float('sphere r',
                                              self.contact_scale,
                                              0.005, 0.0, 1.0)
        if changed or self.load_scene:
            for sphere in self.contact_spheres:
                sphere.set_radius(self.contact_scale)
            self.contact_scale = new_scale
        
        changed, new_scale = imgui.drag_float4('vel', 
                                               *self.velocity_scale,
                                               0.005, 0.0, 100.0)
        if changed or self.load_scene:
            for arrow in self.contact_arrows:
                arrow.set_shaft_length(new_scale[0])
                arrow.set_shaft_radius(new_scale[1])
                arrow.set_head_length(new_scale[2])
                arrow.set_head_radius(new_scale[3])
            self.velocity_scale = new_scale

        changed, new_color = imgui.color_edit4('obs', *self.obstacle_color)
        if changed or self.load_scene:
            [o.set_color(np.array(new_color)) for o in self.system.obstacles]
            self.obstacle_color = new_color

        changed, new_pos = imgui.slider_float3('light', *self.light_pos, -10.0, 10.0)
        if changed or self.load_scene:
            self.light_pos = new_pos
        
        # changed, new_pos = imgui.slider_float3('cam', *self.cam_focus, -10.0, 10.0)
        # if changed or self.load_scene:
        #     self.cam_focus = new_pos

        changed, self.show_grid = imgui.checkbox('grid', self.show_grid)

        changed, self.big_lattice = imgui.checkbox('big lattice', self.big_lattice)

        changed, self.show_contact_frames = imgui.checkbox('frames', self.show_contact_frames)

        changed, self.show_contacts = imgui.checkbox('contacts', self.show_contacts)

        changed, self.show_velocities = imgui.checkbox('velocities', self.show_velocities)
        
        self.load_scene = False
        imgui.end()
コード例 #9
0
def userInterface(graphicItem, app):
    """ Control graphicItem parameters interactively
    """
    imgui.new_frame()
    expanded, opened = imgui.begin('Controls', closable=True,
            flags=imgui.WINDOW_ALWAYS_AUTO_RESIZE)
    if opened:
        # Field to show
        current = app.ifield
        changed, current = imgui.combo('Field', current, list(CHOICES))
        if changed:
            app.setField(current)

        # Speed Rate
        changed, speed = imgui.drag_float('Speed',
            graphicItem.speedFactor, 0.01, 0.0, 10.0)
        if changed:
            graphicItem.speedFactor = speed

        # Decay
        changed, decay = imgui.drag_float('Decay',
            graphicItem.decay, 0.001, 0.001, 1.0)
        if changed:
            graphicItem.decay = decay

        # Drop Rate Bump
        changed, decayBoost = imgui.drag_float('Decay boost',
            graphicItem.decayBoost, 0.01, 0.001, 1.0)
        if changed:
            graphicItem.decayBoost = decayBoost

        # Unknown const
        changed, opacity = imgui.drag_float('Opacity',
            graphicItem.fadeOpacity, 0.001, 0.900, 0.999, '%.4f')
        if changed:
            graphicItem.fadeOpacity = opacity

        # Palette
        changed, color = imgui.color_edit3('Color', *graphicItem.color)
        if changed:
            graphicItem.color = color
        imgui.same_line()
        changed, palette = imgui.checkbox("Palette", graphicItem.palette)
        if changed:
            graphicItem.palette = palette

        changed, bg_color = imgui.color_edit4('Background color',
                *app.bg_color)
        if changed:
            app.bg_color = bg_color

        # Point size
        changed, pointSize = imgui.input_int("Point size",
            graphicItem.pointSize, 1, 1, 1)
        if changed:
            if pointSize > 5:
                pointSize = 5
            elif pointSize < 1:
                pointSize = 1
            graphicItem.pointSize = pointSize

        # Number of Points
        changed, tracersCount = imgui.drag_int("Number of "
            "Tracers", graphicItem.tracersCount, 1000.0, 4000, 10000000)
        if changed:
            graphicItem.tracersCount = tracersCount

        # Periodic border
        changed, periodic = imgui.checkbox("Periodic", graphicItem.periodic)
        if changed:
            graphicItem.periodic = periodic

        # Draw field
        changed, drawfield = imgui.checkbox("Draw Field",
                graphicItem.drawField)
        if changed:
            graphicItem.drawField = drawfield
    imgui.end()
    imgui.render()
    return opened