-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathui.py
92 lines (72 loc) · 2.61 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import bpy
from .generator import Generator
from .operators import (
MESHGEN_OT_CancelGeneration,
MESHGEN_OT_GenerateMesh,
MESHGEN_OT_LoadGenerator,
)
class MESHGEN_PT_Panel(bpy.types.Panel):
bl_label = "Generate"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "MeshGen"
@classmethod
def poll(cls, context):
generator = Generator.instance()
return generator.is_generator_loaded()
def draw(self, context):
layout = self.layout
props = context.scene.meshgen_props
layout.prop(props, "prompt")
layout.separator()
if props.is_running:
layout.operator(
MESHGEN_OT_CancelGeneration.bl_idname, text="Cancel Generation"
)
else:
layout.operator(MESHGEN_OT_GenerateMesh.bl_idname, text="Generate Mesh")
if props.vertices_generated > 0 or props.faces_generated > 0:
layout.separator()
if props.vertices_generated > 0:
layout.label(text=f"Generated {props.vertices_generated} vertices")
if props.faces_generated > 0:
layout.label(text=f"Generated {props.faces_generated} faces")
if not props.is_running:
if props.cancelled:
layout.label(text="Generation cancelled")
else:
layout.label(text="Generation complete")
class MESHGEN_PT_Settings(bpy.types.Panel):
bl_label = "Options"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "MeshGen"
bl_options = {"DEFAULT_CLOSED"}
@classmethod
def poll(cls, context):
generator = Generator.instance()
return generator.is_generator_loaded()
def draw(self, context):
layout = self.layout
props = context.scene.meshgen_props
layout.prop(props, "temperature")
class MESHGEN_PT_Setup(bpy.types.Panel):
bl_label = "Setup"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "MeshGen"
@classmethod
def poll(cls, context):
generator = Generator.instance()
return not generator.is_generator_loaded()
def draw(self, context):
layout = self.layout
layout.operator(MESHGEN_OT_LoadGenerator.bl_idname, text="Load Generator")
def register():
bpy.utils.register_class(MESHGEN_PT_Panel)
bpy.utils.register_class(MESHGEN_PT_Settings)
bpy.utils.register_class(MESHGEN_PT_Setup)
def unregister():
bpy.utils.unregister_class(MESHGEN_PT_Panel)
bpy.utils.unregister_class(MESHGEN_PT_Settings)
bpy.utils.unregister_class(MESHGEN_PT_Setup)