def _update(self): if (self.animate.value): self.generate_items_data() width, height = self.get_window_size() imgui.begin( "Python Plot Benchmark", imgui.Bool(True), imgui.WindowFlags.NoTitleBar | imgui.WindowFlags.NoResize | imgui.WindowFlags.NoMove) imgui.set_window_pos(imgui.Vec2(0, 0)) imgui.set_window_size(imgui.Vec2(width, height)) if (imgui.button("VSync On")): self.set_vsync(True) imgui.same_line() if (imgui.button("VSync Off")): self.set_vsync(False) imgui.same_line() imgui.checkbox("Render", self.render) imgui.same_line() imgui.checkbox("Animate", self.animate) imgui.text("{} lines, {} pts ea. @ {:.3f} FPS".format( self.PLOTS, self.POINTS, imgui.get_io().framerate)) implot.set_next_plot_limits_x(0, self.POINTS) if (implot.begin_plot("##Plot", None, None, imgui.Vec2(-1, -1), implot.Flags.NoChild)): if (self.render.value): for item in self.items: implot.push_style_color(implot.Color.Line, item.color) implot.plot_line(item.label, item.data_x, item.data_y) implot.pop_style_color(implot.Color.Line) implot.end_plot() imgui.end()
def __init__(self): super(MahiRat, self).__init__(800, 800, "Mahi-Gui with ratcave scene renderer") redirect_pyglet() imgui.get_io().ini_filename = None imgui.disable_viewports() self._load_scene()
def _update(self): width, height = self.get_window_size() imgui.begin( "##DDTest", imgui.Bool(True), imgui.WindowFlags.NoTitleBar | imgui.WindowFlags.NoResize | imgui.WindowFlags.NoMove) imgui.set_window_pos(imgui.Vec2(0, 0)) imgui.set_window_size(imgui.Vec2(width, height)) imgui.text("{:.3f} FPS".format(imgui.get_io().framerate)) if imgui.radio_button("Copy", self._mode == self.Mode.COPY): self._mode = self.Mode.COPY imgui.same_line() if imgui.radio_button("Move", self._mode == self.Mode.MOVE): self._mode = self.Mode.MOVE imgui.same_line() if imgui.radio_button("Swap", self._mode == self.Mode.SWAP): self._mode = self.Mode.SWAP for n in range(len(self._names)): imgui.push_id_int(n) if (n % 3) != 0: imgui.same_line() imgui.button(self._names[n], imgui.Vec2(60, 60)) # Our buttons are both drag sources and drag targets here! if imgui.begin_drag_drop_source(imgui.DragDropFlags.None_): # Set payload to carry the index of our item (could be anything) imgui.set_drag_drop_payload_string(str(n)) # Display preview (could be anything, e.g. when dragging an image we could decide to display # the filename and a small preview of the image, etc.) if self._mode == self.Mode.COPY: imgui.text("Copy {}".format(self._names[n])) if self._mode == self.Mode.MOVE: imgui.text("Move {}".format(self._names[n])) if self._mode == self.Mode.SWAP: imgui.text("Swap {}".format(self._names[n])) imgui.end_drag_drop_source() if imgui.begin_drag_drop_target(): payload = imgui.accept_drag_drop_payload_string() if payload: payload_n = int(payload) if self._mode == self.Mode.COPY: self._names[n] = self._names[payload_n] if self._mode == self.Mode.MOVE: self._names[n] = self._names[payload_n] self._names[payload_n] = "" if self._mode == self.Mode.SWAP: tmp = self._names[n] self._names[n] = self._names[payload_n] self._names[payload_n] = tmp imgui.end_drag_drop_target() imgui.pop_id() imgui.end()
def __init__(self): conf = mahi_gui.Application.Config() conf.width = 800 conf.height = 800 conf.title = "Mahi-Gui with ratcave scene renderer" # pyglet uses legacy OpenGL features so we need to enable them # https://pyglet.readthedocs.io/en/latest/programming_guide/context.html conf.gl_forward_compat = False super(MahiRat, self).__init__(conf) redirect_pyglet() imgui.get_io().ini_filename = None imgui.disable_viewports() self._load_scene()
def __init__(self): self.items = [] self.render = imgui.Bool(True) self.animate = imgui.Bool(False) super(PlotBench, self).__init__(500, 500, "Python Plots Benchmark") imgui.get_io().ini_filename = None self.set_vsync(False) imgui.disable_viewports() for i in range(self.PLOTS): item = PlotItem() item.data_x = np.empty(self.POINTS, dtype="uint16") item.data_y = np.empty(self.POINTS) item.color = self.random_color() item.label = "item_{}".format(i) self.items.append(item) self.generate_items_data()
def _update_imgui(self): imgui.set_next_window_size(imgui.Vec2(350, -1), imgui.Condition.Once) imgui.set_next_window_pos(imgui.Vec2(10, 10), imgui.Condition.Once) imgui.begin("Settings") if (imgui.button("VSync On")): self.set_vsync(True) imgui.same_line() if (imgui.button("VSync Off")): self.set_vsync(False) imgui.text("{:.3f} FPS".format(imgui.get_io().framerate)) imgui.spacing() imgui.slider_float("Torus x shift", self._torus_xpos, -3, 3) imgui.spacing() imgui.slider_angle("Camera rotation", self._cam_angle, -180, 180) imgui.slider_float("Camera distance", self._cam_dist, 0, 5) imgui.end()
def __init__(self): super().__init__(210, 250, "Drag&Drop test") imgui.get_io().ini_filename = None self.set_vsync(False) imgui.disable_viewports()
def __init__(self): super().__init__(700, 400, "Hello World") imgui.get_io().ini_filename = None imgui.disable_viewports() self._random = np.random.randn(1000)