mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Remove mobject.save_to_file
This simply didn't work, and had no resilience to changes to the library. For cases where this might be useful, it's likely much better deliberately save specific data which is time-consuming to generate on the fly.
This commit is contained in:
parent
6d0b23f914
commit
7a69807ce6
4 changed files with 0 additions and 71 deletions
|
@ -715,21 +715,6 @@ class Mobject(object):
|
|||
self.become(self.saved_state)
|
||||
return self
|
||||
|
||||
def save_to_file(self, file_path: str) -> Self:
|
||||
with open(file_path, "wb") as fp:
|
||||
fp.write(self.serialize())
|
||||
log.info(f"Saved mobject to {file_path}")
|
||||
return self
|
||||
|
||||
@staticmethod
|
||||
def load(file_path) -> Mobject:
|
||||
if not os.path.exists(file_path):
|
||||
log.error(f"No file found at {file_path}")
|
||||
sys.exit(2)
|
||||
with open(file_path, "rb") as fp:
|
||||
mobject = pickle.load(fp)
|
||||
return mobject
|
||||
|
||||
def become(self, mobject: Mobject, match_updaters=False) -> Self:
|
||||
"""
|
||||
Edit all data and submobjects to be idential
|
||||
|
|
|
@ -460,12 +460,6 @@ class InteractiveScene(Scene):
|
|||
nudge *= 10
|
||||
self.selection.shift(nudge * vect)
|
||||
|
||||
def save_selection_to_file(self):
|
||||
if len(self.selection) == 1:
|
||||
self.save_mobject_to_file(self.selection[0])
|
||||
else:
|
||||
self.save_mobject_to_file(self.selection)
|
||||
|
||||
# Key actions
|
||||
def on_key_press(self, symbol: int, modifiers: int) -> None:
|
||||
super().on_key_press(symbol, modifiers)
|
||||
|
@ -503,8 +497,6 @@ class InteractiveScene(Scene):
|
|||
self.ungroup_selection()
|
||||
elif char == "t" and (modifiers & (PygletWindowKeys.MOD_COMMAND | PygletWindowKeys.MOD_CTRL)):
|
||||
self.toggle_selection_mode()
|
||||
elif char == "s" and (modifiers & (PygletWindowKeys.MOD_COMMAND | PygletWindowKeys.MOD_CTRL)):
|
||||
self.save_selection_to_file()
|
||||
elif char == "d" and (modifiers & PygletWindowKeys.MOD_SHIFT):
|
||||
self.copy_frame_positioning()
|
||||
elif char == "c" and (modifiers & PygletWindowKeys.MOD_SHIFT):
|
||||
|
|
|
@ -710,21 +710,6 @@ class Scene(object):
|
|||
def clear_checkpoints(self):
|
||||
self.checkpoint_manager.clear_checkpoints()
|
||||
|
||||
def save_mobject_to_file(self, mobject: Mobject, file_path: str | None = None) -> None:
|
||||
if file_path is None:
|
||||
file_path = self.file_writer.get_saved_mobject_path(mobject)
|
||||
if file_path is None:
|
||||
return
|
||||
mobject.save_to_file(file_path)
|
||||
|
||||
def load_mobject(self, file_name):
|
||||
if os.path.exists(file_name):
|
||||
path = file_name
|
||||
else:
|
||||
directory = self.file_writer.get_saved_mobject_directory()
|
||||
path = os.path.join(directory, file_name)
|
||||
return Mobject.load(path)
|
||||
|
||||
def is_window_closing(self):
|
||||
return self.window and (self.window.is_closing or self.quit_interaction)
|
||||
|
||||
|
|
|
@ -146,39 +146,6 @@ class SceneFileWriter(object):
|
|||
def get_movie_file_path(self) -> str:
|
||||
return self.movie_file_path
|
||||
|
||||
def get_saved_mobject_directory(self) -> str:
|
||||
return guarantee_existence(self.saved_mobject_directory)
|
||||
|
||||
def get_saved_mobject_path(self, mobject: Mobject) -> str | None:
|
||||
directory = self.get_saved_mobject_directory()
|
||||
files = os.listdir(directory)
|
||||
default_name = str(mobject) + "_0.mob"
|
||||
index = 0
|
||||
while default_name in files:
|
||||
default_name = default_name.replace(str(index), str(index + 1))
|
||||
index += 1
|
||||
if platform.system() == 'Darwin':
|
||||
cmds = [
|
||||
"osascript", "-e",
|
||||
f"""
|
||||
set chosenfile to (choose file name default name "{default_name}" default location "{directory}")
|
||||
POSIX path of chosenfile
|
||||
""",
|
||||
]
|
||||
process = sp.Popen(cmds, stdout=sp.PIPE)
|
||||
file_path = process.stdout.read().decode("utf-8").split("\n")[0]
|
||||
if not file_path:
|
||||
return
|
||||
else:
|
||||
user_name = input(f"Enter mobject file name (default is {default_name}): ")
|
||||
file_path = os.path.join(directory, user_name or default_name)
|
||||
if os.path.exists(file_path) or os.path.exists(file_path + ".mob"):
|
||||
if input(f"{file_path} already exists. Overwrite (y/n)? ") != "y":
|
||||
return
|
||||
if not file_path.endswith(".mob"):
|
||||
file_path = file_path + ".mob"
|
||||
return file_path
|
||||
|
||||
# Sound
|
||||
def init_audio(self) -> None:
|
||||
self.includes_sound: bool = False
|
||||
|
|
Loading…
Add table
Reference in a new issue