mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-31 08:56:34 +00:00
bcf - option to provide snapshot filename + save warnings #4453
Example warning: WARNING. Snapshot with viewpoint guid '6aff8c6e-216c-48c9-8120-3101816def3e' won't be saved to bcf. Only snapshot data (VisualizationInfoHandler.snapshot) is provided and snapshot filename (ViewPoint.snapshot) is missing.
This commit is contained in:
@@ -293,10 +293,13 @@ class TopicHandler:
|
|||||||
self.add_visinfo_handler(vi_handler)
|
self.add_visinfo_handler(vi_handler)
|
||||||
return vi_handler
|
return vi_handler
|
||||||
|
|
||||||
def add_visinfo_handler(self, new_viewpoint: VisualizationInfoHandler) -> mdl.ViewPoint:
|
def add_visinfo_handler(
|
||||||
|
self, new_viewpoint: VisualizationInfoHandler, snapshot_filename: Optional[str] = None
|
||||||
|
) -> mdl.ViewPoint:
|
||||||
self.viewpoints[new_viewpoint.guid + ".bcfv"] = new_viewpoint
|
self.viewpoints[new_viewpoint.guid + ".bcfv"] = new_viewpoint
|
||||||
viewpoint = mdl.ViewPoint(
|
viewpoint = mdl.ViewPoint(
|
||||||
viewpoint=new_viewpoint.guid + ".bcfv",
|
viewpoint=new_viewpoint.guid + ".bcfv",
|
||||||
|
snapshot=snapshot_filename,
|
||||||
guid=new_viewpoint.guid,
|
guid=new_viewpoint.guid,
|
||||||
)
|
)
|
||||||
self.markup.viewpoints.append(viewpoint)
|
self.markup.viewpoints.append(viewpoint)
|
||||||
|
|||||||
@@ -134,6 +134,15 @@ class VisualizationInfoHandler:
|
|||||||
self._save_bitmaps(bcf_zip, topic_dir)
|
self._save_bitmaps(bcf_zip, topic_dir)
|
||||||
|
|
||||||
def _save_snapshot(self, bcf_zip: ZipFileInterface, topic_dir: str, filename: Optional[str]) -> None:
|
def _save_snapshot(self, bcf_zip: ZipFileInterface, topic_dir: str, filename: Optional[str]) -> None:
|
||||||
|
if bool(self.snapshot) ^ bool(filename):
|
||||||
|
data = ["data (VisualizationInfoHandler.snapshot)", "filename (ViewPoint.snapshot)"]
|
||||||
|
provided_data, missing_data = data if self.snapshot else data[::-1]
|
||||||
|
print(
|
||||||
|
f"WARNING. Snapshot with viewpoint guid '{self.guid}' won't be saved to bcf. "
|
||||||
|
f"Only snapshot {provided_data} is provided but snapshot {missing_data} is missing."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
if self.snapshot and filename:
|
if self.snapshot and filename:
|
||||||
bcf_zip.writestr(f"{topic_dir}/{filename}", self.snapshot)
|
bcf_zip.writestr(f"{topic_dir}/{filename}", self.snapshot)
|
||||||
|
|
||||||
|
|||||||
@@ -191,12 +191,15 @@ class TopicHandler:
|
|||||||
self.add_visinfo_handler(vi_handler)
|
self.add_visinfo_handler(vi_handler)
|
||||||
return vi_handler
|
return vi_handler
|
||||||
|
|
||||||
def add_visinfo_handler(self, new_viewpoint: VisualizationInfoHandler) -> mdl.ViewPoint:
|
def add_visinfo_handler(
|
||||||
|
self, new_viewpoint: VisualizationInfoHandler, snapshot_filename: Optional[str] = None
|
||||||
|
) -> mdl.ViewPoint:
|
||||||
self.viewpoints[new_viewpoint.guid + ".bcfv"] = new_viewpoint
|
self.viewpoints[new_viewpoint.guid + ".bcfv"] = new_viewpoint
|
||||||
if self.topic.viewpoints is None:
|
if self.topic.viewpoints is None:
|
||||||
self.topic.viewpoints = mdl.TopicViewpoints()
|
self.topic.viewpoints = mdl.TopicViewpoints()
|
||||||
viewpoint = mdl.ViewPoint(
|
viewpoint = mdl.ViewPoint(
|
||||||
viewpoint=new_viewpoint.guid + ".bcfv",
|
viewpoint=new_viewpoint.guid + ".bcfv",
|
||||||
|
snapshot=snapshot_filename,
|
||||||
guid=new_viewpoint.guid,
|
guid=new_viewpoint.guid,
|
||||||
)
|
)
|
||||||
self.topic.viewpoints.view_point.append(viewpoint)
|
self.topic.viewpoints.view_point.append(viewpoint)
|
||||||
|
|||||||
@@ -133,6 +133,15 @@ class VisualizationInfoHandler:
|
|||||||
self._save_bitmaps(bcf_zip, topic_dir)
|
self._save_bitmaps(bcf_zip, topic_dir)
|
||||||
|
|
||||||
def _save_snapshot(self, bcf_zip: ZipFileInterface, topic_dir: str, filename: Optional[str]) -> None:
|
def _save_snapshot(self, bcf_zip: ZipFileInterface, topic_dir: str, filename: Optional[str]) -> None:
|
||||||
|
if bool(self.snapshot) ^ bool(filename):
|
||||||
|
data = ["data (VisualizationInfoHandler.snapshot)", "filename (ViewPoint.snapshot)"]
|
||||||
|
provided_data, missing_data = data if self.snapshot else data[::-1]
|
||||||
|
print(
|
||||||
|
f"WARNING. Snapshot with viewpoint guid '{self.guid}' won't be saved to bcf. "
|
||||||
|
f"Only snapshot {provided_data} is provided but snapshot {missing_data} is missing."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
if self.snapshot and filename:
|
if self.snapshot and filename:
|
||||||
bcf_zip.writestr(f"{topic_dir}/{filename}", self.snapshot)
|
bcf_zip.writestr(f"{topic_dir}/{filename}", self.snapshot)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user