Skip to content

Commit

Permalink
Added tot frames property and placeholder save param button
Browse files Browse the repository at this point in the history
  • Loading branch information
ruaridhg committed Sep 19, 2023
1 parent 88639fb commit 5fc4ffd
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 18 deletions.
48 changes: 48 additions & 0 deletions randomiser/random_all/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,53 @@ def execute(self, context):
return {"FINISHED"}


# -------------------------------
class ApplySaveParams(bpy.types.Operator):
# docstring shows as a tooltip for menu items and buttons.
"""Save parameter outputs in .json
Parameters
----------
bpy : _type_
_description_
Returns
-------
_type_
_description_
"""

bl_idname = "camera.save_param_out" # appended to bpy.ops.
bl_label = "Save parameter outputs"

bl_options = {"REGISTER", "UNDO"}

@classmethod
def poll(cls, context):
# check the context here
return context.object is not None

def execute(self, context):
"""Execute the save param operator
Save parameter outputs in .json
Parameters
----------
context : _type_
_description_
Returns
-------
_type_
_description_
"""

print("hello")

return {"FINISHED"}


@persistent
def randomise_all_per_frame(dummy):
bpy.ops.camera.randomise_all("INVOKE_DEFAULT")
Expand All @@ -100,6 +147,7 @@ def randomise_all_per_frame(dummy):
# ---------------------
list_classes_to_register = [
ApplyRandomAll,
ApplySaveParams,
]


Expand Down
30 changes: 16 additions & 14 deletions randomiser/random_all/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@

# ---------------------------
# Properties
class PropertiesRandomSeed(bpy.types.PropertyGroup):
class PropertiesRandomAll(bpy.types.PropertyGroup):
"""
Class holding the set of properties
for the random seed
for the randomise all panels
"""

seed_toggle_prop = bpy.props.BoolProperty(
name="Set random seed", default=False
)
seed_toggle: seed_toggle_prop # type: ignore
# seed_toggle_prop = bpy.props.BoolProperty(
# name="Set random seed", default=False
# )
# seed_toggle: seed_toggle_prop # type: ignore

seed_prop = bpy.props.IntProperty(name="Seed", default=42)
seed: seed_prop # type: ignore
tot_frame_no_prop = bpy.props.IntProperty(
name="Total Frame Number", default=50
)
tot_frame_no: tot_frame_no_prop # type: ignore


# ------------------------------------
# Register / unregister classes
# ------------------------------------
list_classes_to_register = [
PropertiesRandomSeed,
PropertiesRandomAll,
]


Expand All @@ -33,11 +35,11 @@ def register():
for cls in list_classes_to_register:
bpy.utils.register_class(cls)

bpy.types.Scene.seed_properties = bpy.props.PointerProperty(
type=PropertiesRandomSeed
bpy.types.Scene.rand_all_properties = bpy.props.PointerProperty(
type=PropertiesRandomAll
)

print("seed properties registered")
print("randomise all properties registered")


def unregister():
Expand All @@ -47,6 +49,6 @@ def unregister():
for cls in list_classes_to_register:
bpy.utils.unregister_class(cls)

del bpy.types.Scene.seed_properties
del bpy.types.Scene.rand_all_properties

print("seed properties unregistered")
print("randomise all properties unregistered")
23 changes: 19 additions & 4 deletions randomiser/random_all/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def draw(self, context):

###################
# Camera positon
row = layout.row() # row = layout.row(align=True)
row.label(text="x")
# row = layout.row() # row = layout.row(align=True)
# row.label(text="x")

row_split = row.split()
col1 = row_split.column(align=True)
# row_split = row.split()
# col1 = row_split.column(align=True)
# col2 = row_split.column(align=True)
# col3 = row_split.column(align=True)
# col4 = row_split.column(align=True)
Expand All @@ -56,6 +56,21 @@ def draw(self, context):
col = self.layout.column()
col.operator("camera.randomise_all", text="Randomise")

# Camera rotation y
row = layout.row()
row.label(text="Save randomisation outputs")
row_split = row.split()
col1 = row_split.column(align=True)
col2 = row_split.column(align=True)

col1.operator("camera.save_param_out", text="Save Parameter Outputs")
# col1.enabled = False
col2.prop(
context.scene.rand_all_properties,
"tot_frame_no",
icon_only=True,
)

# row = self.layout.row(align=True)
# split = row.split()
# left_col = split.column(align=True)
Expand Down

0 comments on commit 5fc4ffd

Please sign in to comment.