Add a button to go back to the beginning

Allows to run benchmark on multiple configurations, without
closing benchmark software.
This commit is contained in:
2018-08-07 10:03:05 +02:00
parent 93c7f172ad
commit c98955b3ff

View File

@@ -45,6 +45,20 @@ images = {}
current_progress = 0.0
progress_lock = Lock()
def reset_global_state():
global global_result_platform
global global_progress_status
global global_result_stats
global global_result_dict
global global_background_image_path
global global_scene_status
global_result_platform = None
global_progress_status = None
global_result_stats = None
global_result_dict = None
global_background_image_path = ""
global_scene_status = {}
################################################################################
# Draw Utilities.
@@ -468,6 +482,11 @@ class BENCHMARK_PT_main(Panel):
sub.scale_y = 1.5
sub.operator("benchmark.save", text="SAVE")
sub = col.row()
sub.emboss = 'NONE'
sub.scale_y = 1.5
sub.operator("benchmark.restart", text="RESTART")
split.label()
def draw(self, context):
@@ -589,7 +608,7 @@ class BENCHMARK_OT_run(bpy.types.Operator):
# Construct final stats string
if global_cancel:
global_result_dict = None
self.init_state()
reset_global_state()
else:
global_result_stats = ""
for stat in global_result_dict["stats"]:
@@ -671,20 +690,6 @@ class BENCHMARK_OT_run(bpy.types.Operator):
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
def init_state(self):
global global_result_platform
global global_progress_status
global global_result_stats
global global_result_dict
global global_background_image_path
global global_scene_status
global_result_platform = None
global_progress_status = None
global_result_stats = None
global_result_dict = None
global_background_image_path = ""
global_scene_status = {}
def cancel_request(self, context):
global global_cancel
progress_lock.acquire()
@@ -743,6 +748,16 @@ class BENCHMARK_OT_share(bpy.types.Operator):
def invoke(self, context, event):
return {'FINISHED'}
################################################################################
# Restart benchmark.
class BENCHMARK_OT_restart(bpy.types.Operator):
bl_idname = "benchmark.restart"
bl_label = "Start new benchmark round"
def invoke(self, context, event):
reset_global_state()
return {'FINISHED'}
################################################################################
# Configuration.
@@ -788,6 +803,7 @@ style.widget.points = 12
classes = (
BENCHMARK_PT_main,
BENCHMARK_OT_restart,
BENCHMARK_OT_run,
BENCHMARK_OT_save,
BENCHMARK_OT_share,