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:
|
||||
self.skip_animations = True
|
||||
if self.file_writer.has_progress_display:
|
||||
if self.file_writer.has_progress_display():
|
||||
self.show_animation_progress = False
|
||||
|
||||
# Items associated with interaction
|
||||
|
@ -471,8 +471,7 @@ class Scene(object):
|
|||
|
||||
times = np.arange(0, run_time, 1 / self.camera.fps)
|
||||
|
||||
if self.file_writer.has_progress_display:
|
||||
self.file_writer.set_progress_display_subdescription(desc)
|
||||
self.file_writer.set_progress_display_description(sub_desc=desc)
|
||||
|
||||
if self.show_animation_progress:
|
||||
return ProgressDisplay(
|
||||
|
|
|
@ -46,14 +46,14 @@ class SceneFileWriter(object):
|
|||
"show_file_location_upon_completion": False,
|
||||
"quiet": False,
|
||||
"total_frames": 0,
|
||||
"progress_description_len": 60,
|
||||
"progress_description_len": 40,
|
||||
}
|
||||
|
||||
def __init__(self, scene, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
self.scene: Scene = scene
|
||||
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.init_output_directories()
|
||||
self.init_audio()
|
||||
|
@ -265,7 +265,7 @@ class SceneFileWriter(object):
|
|||
command += [self.temp_file_path]
|
||||
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(
|
||||
range(self.total_frames),
|
||||
# bar_format="{l_bar}{bar}|{n_fmt}/{total_fmt}",
|
||||
|
@ -273,14 +273,21 @@ class SceneFileWriter(object):
|
|||
ascii=True if platform.system() == 'Windows' else None,
|
||||
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
|
||||
file = os.path.split(self.get_movie_file_path())[1]
|
||||
full_desc = f"Rendering {file} ({sub_desc})"
|
||||
if not file:
|
||||
file = os.path.split(self.get_movie_file_path())[1]
|
||||
full_desc = f"{file} {sub_desc}"
|
||||
if len(full_desc) > desc_len:
|
||||
full_desc = full_desc[:desc_len - 4] + "...)"
|
||||
full_desc = full_desc[:desc_len - 3] + "..."
|
||||
else:
|
||||
full_desc += " " * (desc_len - len(full_desc))
|
||||
self.progress_display.set_description(full_desc)
|
||||
|
@ -289,14 +296,14 @@ class SceneFileWriter(object):
|
|||
if self.write_to_movie:
|
||||
raw_bytes = camera.get_raw_fbo_data()
|
||||
self.writing_process.stdin.write(raw_bytes)
|
||||
if self.has_progress_display:
|
||||
if self.progress_display is not None:
|
||||
self.progress_display.update()
|
||||
|
||||
def close_movie_pipe(self) -> None:
|
||||
self.writing_process.stdin.close()
|
||||
self.writing_process.wait()
|
||||
self.writing_process.terminate()
|
||||
if self.has_progress_display:
|
||||
if self.progress_display is not None:
|
||||
self.progress_display.close()
|
||||
|
||||
if not self.ended_with_interrupt:
|
||||
|
|
Loading…
Add table
Reference in a new issue