Пример #1
0
 def onUpdateUIOverlay(self, overlay):
     if imgui.collapsing_header("Settings"):
         if self.deviceFeatures.fillModeNonSolid:
             res, value = imgui.checkbox("Wireframe", self.wireframe)
             if res:
                 overlay.updated = True
                 self.wireframe = value
                 self.buildCommandBuffers()
         if self.scene:
             res, value = imgui.checkbox("Attach Light", self.attachLight)
             if res:
                 overlay.updated = True
                 self.attachLight = value
                 self.updateUniformBuffers()
             res, value = imgui.checkbox("Render single part",
                                         self.scene.renderSingleScenePart)
             if res:
                 overlay.updated = True
                 self.scene.renderSingleScenePart = value
                 self.buildCommandBuffers()
             if self.scene.renderSingleScenePart:
                 res, value = imgui.slider_int("Part to render",
                                               self.scene.scenePartIndex, 0,
                                               len(self.scene.meshes))
                 if res:
                     overlay.updated = True
                     self.scene.scenePartIndex = value
                     self.buildCommandBuffers()
Пример #2
0
    def kernel_props(self):
        # Kernel Matrix
        expanded1, visible = imgui.collapsing_header(
            'Kernel', self.GUI_STATE.kernelprop.isvisible)
        if expanded1:
            changed0, row = imgui.input_float3(
                ':Kernel R0', *self.GUI_STATE.kernelprop.row[0])
            if changed0:
                self.GUI_STATE.kernelprop.row[0] = row
                for i in range(3):
                    self.SHADER.frame_shader.putDataInUniformLocation(
                        f'kernel[{i}]', self.GUI_STATE.kernelprop.row[0][i])
                self.SHADER.frame_shader.detach()

            changed1, row = imgui.input_float3(
                ':Kernel R1', *self.GUI_STATE.kernelprop.row[1])
            if changed1:
                self.GUI_STATE.kernelprop.row[1] = row
                for i in range(3):
                    print(self.GUI_STATE.kernelprop.row[1][i])
                    self.SHADER.frame_shader.putDataInUniformLocation(
                        f'kernel[{i+3}]',
                        self.GUI_STATE.kernelprop.row[1][i]
                    )

            changed2, row = imgui.input_float3(
                ':Kernel R2', *self.GUI_STATE.kernelprop.row[2])
            if changed2:
                self.GUI_STATE.kernelprop.row[2] = row
                for i in range(3):
                    self.SHADER.frame_shader.putDataInUniformLocation(
                        f'kernel[{i+6}]', self.GUI_STATE.kernelprop.row[2][i])
Пример #3
0
    def draw(self):
        imgui.begin("Example: collapsing header")
        expanded, self.visible = imgui.collapsing_header("Expand me!", self.visible)

        if expanded:
            imgui.text("Now you see me!")
        imgui.end()
Пример #4
0
    def _edit_field_arcs(self, field_geometry: GeometryFieldSize):
        while len(self._field_arc_expanded) < len(field_geometry.field_arcs):
            self._field_arc_expanded.append(False)
        while len(self._field_arc_expanded) > len(field_geometry.field_arcs):
            del self._field_arc_expanded[-1]

        imgui.text("Field Arcs")
        imgui.separator()
        arcs_to_delete = []
        for i, arc in enumerate(field_geometry.field_arcs):
            expanded, visible = imgui.collapsing_header(
                arc.name,
                True,
                imgui.TREE_NODE_DEFAULT_OPEN
                if self._field_arc_expanded[i] else 0,
            )
            if not visible:
                arcs_to_delete.append(i)
            if expanded:
                self._field_arc_expanded[i] = True
                changed, value = imgui.input_text(f"Name##{i}", arc.name, 255)
                if changed:
                    arc.name = value
                changed, values = imgui.input_float2("Center", arc.center.x,
                                                     arc.center.y)
                if changed:
                    arc.center.x, arc.center.y = values
                changed, values = imgui.input_float(f"Radius##{i}", arc.radius)
                if changed:
                    if value > 0:
                        arc.radius = value
                    else:
                        self._log.error(
                            f"Arc radius must be > 0. Got {arc.radius}")
                changed, values = imgui.input_float2(
                    f"Start Angle, End Angle##{i}", arc.a1, arc.a2)
                if changed:
                    arc.a1, arc.a2 = sorted(values)
                changed, value = imgui.input_float(f"Thickness##{i}",
                                                   arc.thickness)
                if changed:
                    if value > 0:
                        arc.thickness = value
                    else:
                        self._log.error("Field arc must have thickness > 0. "
                                        f"Got {arc.thickness}")
        for arc in arcs_to_delete[::-1]:
            del field_geometry.field_arcs[arc]
            del self._field_arc_expanded[arc]
        if imgui.button("Add field arc"):
            new_arc = field_geometry.field_arcs.add()
            new_arc.radius = 1000
            new_arc.thickness = 10
            self._field_arc_expanded.append(False)
Пример #5
0
 def onUpdateUIOverlay(self, overlay):
     #return
     if imgui.collapsing_header("Settings"):
         res, value = imgui.slider_float("LOD bias",
                                         self.uboVS['lodBias'].x, 0.0,
                                         self.texture.mipLevels)
         #res = False
         if res:
             overlay.updated = True
             self.uboVS['lodBias'].x = value
             self.updateUniformBuffers()
Пример #6
0
def collapsing_header(text, widget, open=True):
    """Display a collapsible section header. It can be open or closed by default (parameter `open`).
    """
    while True:
        expanded, visible = imgui.collapsing_header(
            text, flags=open and imgui.TREE_NODE_DEFAULT_OPEN)
        try:
            if expanded:
                next(widget)
        except StopIteration as e:
            return e.value
        yield
Пример #7
0
 def vanilla_view_props(self):
     # Vanilla Render View
     expanded0, visible = imgui.collapsing_header(
         'Raw Scene', self.GUI_STATE.renderprop.isvisible)
     if expanded0:
         imgui.image(self.GUI_STATE.renderprop.img, 256, 256, (0, 1),
                     (1, 0), border_color=(0.5, 0.3, 0.2, 1.0))
         changed, self.GUI_STATE.renderprop.gamma = imgui.input_float(
             ' : Gamma', self.GUI_STATE.renderprop.gamma)
         # self.SHADER.frame_shader.attach()
         self.SHADER.frame_shader.putDataInUniformLocation(
             'gamma', self.GUI_STATE.renderprop.gamma)
Пример #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'
             )
 def _draw_initial_state(self):
     expanded, _ = imgui.collapsing_header("Initial State")
     if expanded:
         changed, values = imgui.input_float2("Position (x, y)",
                                              self.initial_state[0],
                                              self.initial_state[2])
         if changed:
             self.is_dirty = True
             self.initial_state[0], self.initial_state[2] = values
         changed, values = imgui.input_float2("Velocity (x, y)",
                                              self.initial_state[1],
                                              self.initial_state[3])
         if changed:
             self.is_dirty = True
             self.initial_state[1], self.initial_state[3] = values
Пример #10
0
    def _edit_field_lines(self, field_geometry: GeometryFieldSize):
        while len(self._field_line_expanded) < len(field_geometry.field_lines):
            self._field_line_expanded.append(False)
        while len(self._field_line_expanded) > len(field_geometry.field_lines):
            del self._field_line_expanded[-1]

        imgui.text("Field Lines")
        imgui.separator()
        lines_to_delete = []
        for i, line in enumerate(field_geometry.field_lines):
            expanded, visible = imgui.collapsing_header(
                f"{line.name}##{i}",
                True,
                imgui.TREE_NODE_DEFAULT_OPEN
                if self._field_line_expanded[i] else 0,
            )
            if not visible:
                lines_to_delete.append(i)
            if expanded:
                self._field_line_expanded[i] = True
                changed, value = imgui.input_text(f"Name##{i}", line.name, 255)
                if changed:
                    line.name = value
                changed, values = imgui.input_float2(f"P1##{i}", line.p1.x,
                                                     line.p1.y)
                if changed:
                    line.p1.x, line.p1.y = values[0], values[1]
                changed, values = imgui.input_float2(f"P2##{i}", line.p2.x,
                                                     line.p2.y)
                if changed:
                    line.p2.x, line.p2.y = values[0], values[1]
                changed, value = imgui.input_float(f"Thickness##{i}",
                                                   line.thickness)
                if changed:
                    if value > 0:
                        line.thickness = value
                    else:
                        self._log.error("Field line must have thickness > 0. "
                                        f"Got {line.thickness}")
            else:
                self._field_line_expanded[i] = False
        for line in lines_to_delete[::-1]:
            del field_geometry.field_lines[line]
            del self._field_line_expanded[line]
        if imgui.button("Add field line"):
            new_line = field_geometry.field_lines.add()
            new_line.thickness = 10
            self._field_line_expanded.append(False)
Пример #11
0
    def displayInspector(self, obj):
        imgui.set_next_window_position(self.position[0], self.position[1])
        imgui.set_next_window_size(self.width, self.height)

        expanded, opened = imgui.begin("Inspector", True)
        if opened:
            imgui.begin_group()
            imgui.bullet_text(obj.name)

            transform_layer, visible = imgui.collapsing_header(
                "Transform", True)
            if transform_layer:
                HELPER.displayGameObjectTransformSetting(obj, imgui)
            imgui.end_group()

            for component in obj.components:
                HELPER.displayComponentSetting(imgui, component, obj)
        imgui.end()
    def _draw_R(self, ball_filter: BasicBallFilter):
        expanded, _ = imgui.collapsing_header("R")
        if expanded:
            changed, values = imgui.input_float2("R[0, :]", ball_filter.R[0,
                                                                          0],
                                                 ball_filter.R[0, 1])
            if changed:
                if values[0] >= 0 and values[1] >= 0:
                    self.is_dirty = True
                    ball_filter.R[0, :] = values

            changed, values = imgui.input_float2("R[1, :]", ball_filter.R[1,
                                                                          0],
                                                 ball_filter.R[1, 1])
            if changed:
                if values[0] >= 0 and values[1] >= 0:
                    self.is_dirty = True
                    ball_filter.R[1, :] = values
Пример #13
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: collapsing header")
        expanded, self.visible = imgui.collapsing_header(
            "Expand me!", self.visible)

        if expanded:
            imgui.text("Now you see me!")
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
Пример #14
0
def flightDropDown(flight_name, flight):
    # create the drop down with the flight location and date
    expanded, _ = imgui.collapsing_header(flight.getLocationName() + " (" +
                                          flight.getFlightDate() + ")##" +
                                          str(flight.id))

    if expanded:
        #Display flight stats if the drop down is visible
        imgui.text("Flight Time: " + str(flight.getFlightTime()) + "h")
        imgui.same_line()
        imgui.text("| Batteries Used: " + str(flight.getBatteriesUsed()))
        imgui.text("Location: " + flight.getLocationName())
        imgui.text("Flight has Panorama: " +
                   str(flight.media.flightHasPanoramas))
        imgui.separator()
        if imgui.button("Open in File Browser"):
            os.startfile(flight.flight_directory)
        imgui.spacing()
        # code for each media type drop down
        mediaDropDown(flight)
        imgui.spacing()
 def _draw_initial_P(self):
     expanded, _ = imgui.collapsing_header("Initial P diagonals")
     if expanded:
         changed, values = imgui.input_float2("Position Uncertainty (x, y)",
                                              self.initial_P[0],
                                              self.initial_P[2])
         if changed:
             if values[0] >= 0 and values[1] >= 0:
                 self.is_dirty = True
                 self.initial_P[0], self.initial_P[2] = values
             else:
                 self._log.error(
                     f"Position uncertainty must be >= 0. Got {values}")
         changed, values = imgui.input_float2("Velocity Uncertainty (x, y)",
                                              self.initial_P[1],
                                              self.initial_P[3])
         if changed:
             if values[0] >= 0 and values[1] >= 0:
                 self.is_dirty = True
                 self.initial_P[1], self.initial_P[3] = values
             else:
                 self._log.error(
                     f"Velocity uncertainty must be >= 0. Got {values}")
Пример #16
0
def draw_ui():
    """ Draws the imgui UI """
    global g_cube
    global g_cam
    global g_light_1
    global g_light_color_1
    global g_light_2
    global g_light_color_2
    global g_light_3
    global g_light_color_3
    global g_light_4
    global g_light_color_4
    global g_ambi_color
    global g_spec_color
    global g_fog_color
    global g_fog_density
    global g_fog_height
    global g_fog_max

    global g_move_string

    btn_w = 25
    imgui.set_window_font_scale(1.2)

    _, g_cam = imgui.slider_float3(
        "Camera Position", *g_cam, min_value=-20.0, max_value=150.0)
    g_cam = list(g_cam)

    expanded, _ = imgui.collapsing_header("Controls", True)
    if expanded:
        # Rubiks Cube Moves
        imgui.begin_group()
        imgui.text("Moves:")

        add_move_buttons("F", g_cube.move_f, btn_w)
        imgui.same_line(spacing=20)
        add_move_buttons("B", g_cube.move_b, btn_w)
        add_move_buttons("R", g_cube.move_r, btn_w)
        imgui.same_line(spacing=20)
        add_move_buttons("L", g_cube.move_l, btn_w)
        add_move_buttons("U", g_cube.move_u, btn_w)
        imgui.same_line(spacing=20)
        add_move_buttons("D", g_cube.move_d, btn_w)

        imgui.end_group()

        imgui.same_line(spacing=50)

        # Cube Rotations
        imgui.begin_group()
        imgui.text("Rotations:")
        add_move_buttons("x", g_cube.rotate_x, btn_w)
        add_move_buttons("y", g_cube.rotate_y, btn_w)
        add_move_buttons("z", g_cube.rotate_z, btn_w)
        imgui.end_group()

        _, g_move_string = imgui.core.input_text("", g_move_string, 64)
        imgui.same_line(spacing=10)
        clicked = imgui.button("Perform")
        if clicked:
            parse_moves()

    expanded, _ = imgui.collapsing_header("View Settings", True)
    if expanded:
        # Light 1
        expanded, _ = imgui.collapsing_header("Light 1", True)
        if expanded:
            _, g_light_1 = imgui.slider_float3(
                "Position 1", *g_light_1, min_value=-20.0, max_value=20.0)
            _, g_light_color_1 = imgui.color_edit3("Colour 1", *g_light_color_1)
            g_light_1 = list(g_light_1)
            g_light_color_1 = list(g_light_color_1)
        # Light 2
        expanded, _ = imgui.collapsing_header("Light 2", True)
        if expanded:
            _, g_light_2 = imgui.slider_float3(
                "Position 2", *g_light_2, min_value=-20.0, max_value=20.0)
            _, g_light_color_2 = imgui.color_edit3("Colour 2", *g_light_color_2)
            g_light_2 = list(g_light_2)
            g_light_color_2 = list(g_light_color_2)
        # Light 3
        expanded, _ = imgui.collapsing_header("Light 3", True)
        if expanded:
            _, g_light_3 = imgui.slider_float3(
                "Position 3 ", *g_light_3, min_value=-20.0, max_value=20.0)
            _, g_light_color_3 = imgui.color_edit3("Colour 3", *g_light_color_3)
            g_light_3 = list(g_light_3)
            g_light_color_3 = list(g_light_color_3)
        # Light 4
        expanded, _ = imgui.collapsing_header("Light 4", True)
        if expanded:
            _, g_light_4 = imgui.slider_float3(
                "Position 4", *g_light_4, min_value=-20.0, max_value=20.0)
            _, g_light_color_4 = imgui.color_edit3("Colour 4", *g_light_color_4)
            g_light_4 = list(g_light_4)
            g_light_color_4 = list(g_light_color_4)
        # Other Light constants
        expanded, _ = imgui.collapsing_header("Other Lighting", True)
        if expanded:
            _, g_ambi_color = imgui.color_edit3("Ambient Light Colour",
                                                *g_ambi_color)
            _, g_spec_color = imgui.color_edit3("Specular Light Colour",
                                                *g_spec_color)
            g_ambi_color = list(g_ambi_color)
            g_spec_color = list(g_spec_color)
        expanded, _ = imgui.collapsing_header("Fog Settings", True)
        if expanded:
            _, g_fog_color = imgui.color_edit3("Fog Colour", *g_fog_color)
            g_fog_color = list(g_fog_color)
            _, g_fog_density = imgui.input_float("Fog Density Coefficient",
                                                 g_fog_density)
            _, g_fog_height = imgui.input_float("Fog Height Coefficient",
                                                g_fog_height)
            _, g_fog_max = imgui.input_float("Max Fog", g_fog_max)
Пример #17
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()
Пример #18
0
    def make_gui(self, width, height):
        imgui.begin("Lighting", True)

        imgui.collapsing_header("Shadows")
        imgui.indent()
        ch, val = imgui.checkbox("Render Shadows", self.scene.shadowsEnabled)
        if ch:
            self.scene.shadowsEnabled = val
            if not val:
                self.scene.shadows.clear()

        ch, val = imgui.slider_float("Shadow Strength",
                                     self.lightingStage.shadowStrength, 0, 1)
        if ch:
            self.lightingStage.shadowStrength = val

        ch, val = imgui.slider_int("Shadows Update Frequency",
                                   self.scene.shadows.exponent, 1, 10)
        if ch:
            self.scene.shadows.exponent = val

        ch, val = imgui.slider_float("Shadows range", self.scene.shadows.rng,
                                     0.01, 20)
        if ch:
            self.scene.shadows.rng = val
        imgui.unindent()

        imgui.collapsing_header("Ambient Occlusion")
        imgui.indent()

        ch, val = imgui.slider_float("Occlusion Strength",
                                     self.lightingStage.occlusionStrength, 0,
                                     1)
        if ch:
            self.lightingStage.occlusionStrength = val

        ch, val = imgui.slider_float(
            "SSAO blur radius",
            self.lightingStage.SSAOBlurAmount,
            0,
            0.01,
            display_format="%.4f",
        )
        if ch:
            self.lightingStage.SSAOBlurAmount = val

        ch, val = imgui.slider_int("SSAO Samples",
                                   self.lightingStage.SSAOSamples, 0, 20)
        if ch:
            self.lightingStage.SSAOSamples = val

        ch, val = imgui.slider_float("SSAO Radius",
                                     self.lightingStage.SSAORadius, 0, 2)
        if ch:
            self.lightingStage.SSAORadius = val

        ch, val = imgui.slider_float("SSAO Min Cutoff",
                                     self.lightingStage.SSAOMin, 0, 1)
        if ch:
            self.lightingStage.SSAOMin = val

        ch, val = imgui.slider_float("SSAO Max Cutoff",
                                     self.lightingStage.SSAOMax, 0, 1)
        if ch:
            self.lightingStage.SSAOMax = val

        imgui.unindent()

        imgui.collapsing_header("Raytracing")
        imgui.indent()

        ch, val = imgui.slider_int("Raytrace Count",
                                   self.lightingStage.raytraceCount, 0, 100)
        if ch:
            self.lightingStage.raytraceCount = val

        ch, val = imgui.slider_float("Raytrace Strength",
                                     self.lightingStage.raytraceStrength, 0, 1)
        if ch:
            self.lightingStage.raytraceStrength = val

        imgui.unindent()

        imgui.collapsing_header("Other")
        imgui.indent()

        ch, val = imgui.slider_float("Ambient light strength",
                                     self.lightingStage.ambientStrength, 0, 1)
        if ch:
            self.lightingStage.ambientStrength = val

        ch, val = imgui.slider_float("Sun Intesnity",
                                     self.lightingStage.sunIntensity, 0, 1)
        if ch:
            self.lightingStage.sunIntensity = val

        ch, val = imgui.slider_float("Specularity",
                                     self.lightingStage.specularity,
                                     1,
                                     10000,
                                     power=10)
        if ch:
            self.lightingStage.specularity = val
        imgui.unindent()

        imgui.end()
Пример #19
0
 def render(self):
     expanded, visible = imgui.collapsing_header(self.exception)
     if expanded:
         imgui.text(self.traceinfo)
Пример #20
0
def main():
    pygame.init()
    display = (1000, 700)
    screen = pygame.display.set_mode(display, DOUBLEBUF | OPENGLBLIT)
    imgui.create_context()
    impl = PygameRenderer()
    io = imgui.get_io()
    io.display_size = display
    pygame.display.set_caption('solar panels')
    gluPerspective(45, (display[0] / display[1]), 0.1, 50.0)
    glTranslatef(0, 0, -10)

    glRotatef(25, 2, 1, 0)

    # Coordinates
    x = 0
    y = 0
    z = 0
    a = 0
    # Keystates
    KLEFT = False
    KRIGHT = False
    KUP = False
    KDOWN = False
    KJ = False
    KL = False
    KA = False
    KD = False
    KW = False
    KS = False
    KI = False
    KK = False
    KG = False
    KH = False
    b = 0
    d = 0
    c = 1
    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
            # KEYEVENT KEYDOWN HANDLING
            if event.type == pygame.KEYDOWN:
                # TRANSLATE
                if event.key == pygame.K_LEFT:
                    KLEFT = True
                if event.key == pygame.K_RIGHT:
                    KRIGHT = True
                if event.key == pygame.K_UP:
                    KUP = True
                if event.key == pygame.K_DOWN:
                    KDOWN = True
                if event.key == pygame.K_j:
                    KJ = True
                if event.key == pygame.K_l:
                    KL = True

                # ROTATE
                if event.key == pygame.K_a:
                    KA = True
                if event.key == pygame.K_d:
                    KD = True
                if event.key == pygame.K_w:
                    KW = True
                if event.key == pygame.K_s:
                    KS = True
                if event.key == pygame.K_i:
                    KI = True
                if event.key == pygame.K_k:
                    KK = True
                # Arm Control
                # Optional key usage to move arm model

                if event.key == pygame.K_g:
                    KG = True
                if event.key == pygame.K_h:
                    KH = True

            # KEYEVENT KEYUP HANDLING
            if event.type == pygame.KEYUP:
                # TRANSLATE
                if event.key == pygame.K_LEFT:
                    KLEFT = False
                if event.key == pygame.K_RIGHT:
                    KRIGHT = False
                if event.key == pygame.K_UP:
                    KUP = False
                if event.key == pygame.K_DOWN:
                    KDOWN = False
                if event.key == pygame.K_j:
                    KJ = False
                if event.key == pygame.K_l:
                    KL = False

                # ROTATE
                if event.key == pygame.K_a:
                    KA = False
                if event.key == pygame.K_d:
                    KD = False
                if event.key == pygame.K_w:
                    KW = False
                if event.key == pygame.K_s:
                    KS = False
                if event.key == pygame.K_i:
                    KI = False
                if event.key == pygame.K_k:
                    KK = False

                # Arm Angle
                # Optional key usage to move arm model

                if event.key == pygame.K_g:
                    KG = False
                if event.key == pygame.K_h:
                    KH = False

        # KEY PRESS ACTIONS

        # TRANSLATE

        if KH == True:
            glTranslatef(0, -1, 0)
            y += 1
        if KG == True:
            glTranslatef(0, 1, 0)
            y -= 1
        if KJ == True:
            glTranslatef(0, 0, -1)
            z += 1
        if KL == True:
            glTranslatef(0, 0, 1)
            z -= 1

        # ROTATE

        if KI == True:
            glRotate(5, 0, 1, 0)
        if KK == True:
            glRotate(5, 0, 0, 1)
        # Arm Angle
        # Optional key usage to move arm model
        if KRIGHT == True:
            a += 1

        if KLEFT == True:
            a -= 1
        if KUP == True:
            b += 1

        if KDOWN == True:
            b -= 1
        if KA == True:
            c += 1

        if KD == True:
            c -= 1
        if KW == True:
            d += 1
        if KS == True:
            d -= 1

        impl.process_event(event)
        imgui.new_frame()
        imgui.begin("Controle du Mirroir", True)
        imgui.text("Les Angles")

        c = imgui.slider_int("Axe des x", c, -180., 180.)[1]
        a = imgui.slider_int("Axe des y", a, -180., 180.)[1]
        changed, c = imgui.input_int('Type coefficient:', c)
        imgui.text('The Va;ue you entered is: %f' % c)
        visible = True
        expanded, visible = imgui.collapsing_header("Expand me!", visible)
        if expanded:
            imgui.text("Now you see me qnd perhaps you don't !")
            imgui.show_style_editor()

        imgui.end()

        imgui.render()

        gl.glClearColor(1, 1, 1, 1)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        impl.render(imgui.get_draw_data())

        glPushMatrix()
        house()
        glPopMatrix()
        glPushMatrix()
        house()
        Mirroir(c, a)
        glPopMatrix()
        glPushMatrix()
        mirroir2(c, a)
        glRotate(180, 0, 1, 0)

        glPopMatrix()
        glPushMatrix()
        support(c, a)
        glPopMatrix()
        support2()

        pygame.display.flip()
Пример #21
0
def render():
    global selected_index, selected_file, clones_for_file, padding

    imgui.set_next_window_position(10, 10)
    imgui.set_next_window_size(280, 375)
    imgui.begin(
        "Clone Classes", False, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE
        | imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_MENU_BAR)

    if imgui.begin_menu_bar():
        if imgui.begin_menu('Sort'):
            clicked, _ = imgui.menu_item('identifier (ascending)')
            if clicked:
                clones.sort(key=lambda x: x.class_identifier)

            clicked, _ = imgui.menu_item('identifier (descending)')
            if clicked:
                clones.sort(key=lambda x: x.class_identifier, reverse=True)

            clicked, _ = imgui.menu_item('clones (ascending)')
            if clicked:
                clones.sort(key=lambda x: x.num_clones)

            clicked, _ = imgui.menu_item('clones (descending)')
            if clicked:
                clones.sort(key=lambda x: x.num_clones, reverse=True)

            clicked, _ = imgui.menu_item('files (ascending)')
            if clicked:
                clones.sort(key=lambda x: len(x.files))

            clicked, _ = imgui.menu_item('files (descending)')
            if clicked:
                clones.sort(key=lambda x: len(x.files), reverse=True)

            imgui.end_menu()

        imgui.end_menu_bar()

    for index, clone_class in enumerate(clones):

        if selected_index is clone_class.class_identifier:
            label = "--> Class {0:03d} ({1} files, {2} clones)".format(
                clone_class.class_identifier, len(clone_class.files),
                clone_class.num_clones)
        else:
            label = "Class {0:03d} ({1} files, {2} clones)".format(
                clone_class.class_identifier, len(clone_class.files),
                clone_class.num_clones)

        if imgui.button(label, width=260):
            select_clone(clone_class.class_identifier)

    imgui.end()

    imgui.set_next_window_position(10, 390)
    imgui.set_next_window_size(280, 380)
    imgui.begin(
        "Files", False, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE
        | imgui.WINDOW_NO_COLLAPSE)

    for index, file_name in enumerate(unique_file_name):
        if selected_file is file_name:
            label = "--> {}".format(os.path.basename(file_name))
        else:
            label = "{}".format(os.path.basename(file_name))

        if imgui.button(label, width=260):
            select_file(file_name)

    imgui.end()

    imgui.set_next_window_position(300, 10)
    imgui.set_next_window_size(890, 760)
    imgui.begin(
        "Details", False, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE
        | imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_HORIZONTAL_SCROLLING_BAR
        | imgui.WINDOW_MENU_BAR)

    if selected_file is not None and clones_for_file is not None:
        if imgui.begin_menu_bar():
            if imgui.begin_menu('Actions'):
                clicked, _ = imgui.menu_item('Open in editor')

                if clicked:
                    os.system("open \"{}\"".format(selected_file))

                imgui.end_menu()

            imgui.end_menu_bar()

        file_buffer = file_buffers[selected_file]

        total_cloned_lines = 0
        for _, file in clones_for_file:
            total_cloned_lines += file.num_cloned_lines

        imgui.begin_group()
        imgui.text("Information for this file")
        imgui.bullet_text("This file contains {} lines".format(
            file_buffer.max_line))
        imgui.bullet_text("{} lines are cloned".format(total_cloned_lines))
        imgui.bullet_text("That is {0:.2f}% of the total file".format(
            total_cloned_lines / file_buffer.max_line * 100))
        imgui.end_group()

        imgui.same_line(300)

        imgui.push_item_width(200)
        imgui.begin_group()
        changed, value = imgui.slider_int("Lines of padding", padding, 0, 100)
        if changed:
            padding = value
        imgui.end_group()
        imgui.pop_item_width()

        imgui.spacing()
        imgui.spacing()
        imgui.spacing()
        imgui.spacing()

        for class_identifier, file in clones_for_file:
            expanded, visible = imgui.collapsing_header(
                "Clone class {0:03d}".format(class_identifier), None,
                imgui.TREE_NODE_DEFAULT_OPEN)

            if expanded:
                if imgui.button(
                        "View all files for clone class {0:03d}".format(
                            class_identifier)):
                    select_clone(class_identifier)

                file_buffers[file.file_name].to_imgui(file, padding)

    if selected_index is not None:
        imgui.push_item_width(200)
        imgui.begin_group()
        changed, value = imgui.slider_int("Lines of padding", padding, 0, 100)
        if changed:
            padding = value
        imgui.end_group()
        imgui.pop_item_width()

        clone_class = None

        for clone in clones:
            if clone.class_identifier is selected_index:
                clone_class = clone

        for i, file in enumerate(clone_class.files):
            expanded, visible = imgui.collapsing_header(
                file.file_name, None, imgui.TREE_NODE_DEFAULT_OPEN)

            if expanded:
                if imgui.button("View all clones for \"{}\"".format(
                        file.file_name)):
                    select_file(file.file_name)

                file_buffers[file.file_name].to_imgui(file, padding)

    imgui.end()