mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Change/refactor progress display defaults in scene file writing
This commit is contained in:
parent
8cc7616271
commit
7de03e2541
2 changed files with 19 additions and 13 deletions
|
@ -92,7 +92,7 @@ class Scene(object):
|
||||||
|
|
||||||
if self.start_at_animation_number is not None:
|
if self.start_at_animation_number is not None:
|
||||||
self.skip_animations = True
|
self.skip_animations = True
|
||||||
if self.file_writer.has_progress_display:
|
if self.file_writer.has_progress_display():
|
||||||
self.show_animation_progress = False
|
self.show_animation_progress = False
|
||||||
|
|
||||||
# Items associated with interaction
|
# Items associated with interaction
|
||||||
|
@ -471,8 +471,7 @@ class Scene(object):
|
||||||
|
|
||||||
times = np.arange(0, run_time, 1 / self.camera.fps)
|
times = np.arange(0, run_time, 1 / self.camera.fps)
|
||||||
|
|
||||||
if self.file_writer.has_progress_display:
|
self.file_writer.set_progress_display_description(sub_desc=desc)
|
||||||
self.file_writer.set_progress_display_subdescription(desc)
|
|
||||||
|
|
||||||
if self.show_animation_progress:
|
if self.show_animation_progress:
|
||||||
return ProgressDisplay(
|
return ProgressDisplay(
|
||||||
|
|
|
@ -46,14 +46,14 @@ class SceneFileWriter(object):
|
||||||
"show_file_location_upon_completion": False,
|
"show_file_location_upon_completion": False,
|
||||||
"quiet": False,
|
"quiet": False,
|
||||||
"total_frames": 0,
|
"total_frames": 0,
|
||||||
"progress_description_len": 60,
|
"progress_description_len": 40,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, scene, **kwargs):
|
def __init__(self, scene, **kwargs):
|
||||||
digest_config(self, kwargs)
|
digest_config(self, kwargs)
|
||||||
self.scene: Scene = scene
|
self.scene: Scene = scene
|
||||||
self.writing_process: sp.Popen | None = None
|
self.writing_process: sp.Popen | None = None
|
||||||
self.has_progress_display: bool = False
|
self.progress_display: ProgressDisplay | None = None
|
||||||
self.ended_with_interrupt: bool = False
|
self.ended_with_interrupt: bool = False
|
||||||
self.init_output_directories()
|
self.init_output_directories()
|
||||||
self.init_audio()
|
self.init_audio()
|
||||||
|
@ -265,7 +265,7 @@ class SceneFileWriter(object):
|
||||||
command += [self.temp_file_path]
|
command += [self.temp_file_path]
|
||||||
self.writing_process = sp.Popen(command, stdin=sp.PIPE)
|
self.writing_process = sp.Popen(command, stdin=sp.PIPE)
|
||||||
|
|
||||||
if self.total_frames > 0:
|
if self.total_frames > 0 and not self.quiet:
|
||||||
self.progress_display = ProgressDisplay(
|
self.progress_display = ProgressDisplay(
|
||||||
range(self.total_frames),
|
range(self.total_frames),
|
||||||
# bar_format="{l_bar}{bar}|{n_fmt}/{total_fmt}",
|
# bar_format="{l_bar}{bar}|{n_fmt}/{total_fmt}",
|
||||||
|
@ -273,14 +273,21 @@ class SceneFileWriter(object):
|
||||||
ascii=True if platform.system() == 'Windows' else None,
|
ascii=True if platform.system() == 'Windows' else None,
|
||||||
dynamic_ncols=True,
|
dynamic_ncols=True,
|
||||||
)
|
)
|
||||||
self.has_progress_display = True
|
self.set_progress_display_description()
|
||||||
|
|
||||||
|
def has_progress_display(self):
|
||||||
|
return self.progress_display is not None
|
||||||
|
|
||||||
|
def set_progress_display_description(self, file: str = "", sub_desc: str = "") -> None:
|
||||||
|
if self.progress_display is None:
|
||||||
|
return
|
||||||
|
|
||||||
def set_progress_display_subdescription(self, sub_desc: str) -> None:
|
|
||||||
desc_len = self.progress_description_len
|
desc_len = self.progress_description_len
|
||||||
|
if not file:
|
||||||
file = os.path.split(self.get_movie_file_path())[1]
|
file = os.path.split(self.get_movie_file_path())[1]
|
||||||
full_desc = f"Rendering {file} ({sub_desc})"
|
full_desc = f"{file} {sub_desc}"
|
||||||
if len(full_desc) > desc_len:
|
if len(full_desc) > desc_len:
|
||||||
full_desc = full_desc[:desc_len - 4] + "...)"
|
full_desc = full_desc[:desc_len - 3] + "..."
|
||||||
else:
|
else:
|
||||||
full_desc += " " * (desc_len - len(full_desc))
|
full_desc += " " * (desc_len - len(full_desc))
|
||||||
self.progress_display.set_description(full_desc)
|
self.progress_display.set_description(full_desc)
|
||||||
|
@ -289,14 +296,14 @@ class SceneFileWriter(object):
|
||||||
if self.write_to_movie:
|
if self.write_to_movie:
|
||||||
raw_bytes = camera.get_raw_fbo_data()
|
raw_bytes = camera.get_raw_fbo_data()
|
||||||
self.writing_process.stdin.write(raw_bytes)
|
self.writing_process.stdin.write(raw_bytes)
|
||||||
if self.has_progress_display:
|
if self.progress_display is not None:
|
||||||
self.progress_display.update()
|
self.progress_display.update()
|
||||||
|
|
||||||
def close_movie_pipe(self) -> None:
|
def close_movie_pipe(self) -> None:
|
||||||
self.writing_process.stdin.close()
|
self.writing_process.stdin.close()
|
||||||
self.writing_process.wait()
|
self.writing_process.wait()
|
||||||
self.writing_process.terminate()
|
self.writing_process.terminate()
|
||||||
if self.has_progress_display:
|
if self.progress_display is not None:
|
||||||
self.progress_display.close()
|
self.progress_display.close()
|
||||||
|
|
||||||
if not self.ended_with_interrupt:
|
if not self.ended_with_interrupt:
|
||||||
|
|
Loading…
Add table
Reference in a new issue