Esempio n. 1
0
    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()
Esempio n. 2
0
    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()
Esempio n. 3
0
    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()