Skip to content

Commit 64cc8b1

Browse files
committed
split vtk and png plot modes
1 parent 9710051 commit 64cc8b1

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

pypeec/lib_check/check_data_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def check_plot_options(plot_mode, folder, name):
4646
# check plot_mode
4747
schema = {
4848
"type": ["null", "string"],
49-
"enum": [None, "qt", "nb_int", "nb_std", "save", "debug"],
49+
"enum": [None, "qt", "nb_int", "nb_std", "png", "vtk", "debug"],
5050
}
5151
scisave.validate_schema(plot_mode, schema)
5252

pypeec/lib_plot/manage_plotgui.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def _get_filename(self, tag, ext):
312312

313313
def _save_screenshot(self):
314314
"""
315-
Save all the plots as images.
315+
Save all the plot content as PNG files.
316316
"""
317317

318318
# save the PyVista plots
@@ -325,7 +325,11 @@ def _save_screenshot(self):
325325
filename = self._get_filename(tag, "png")
326326
fig.savefig(filename)
327327

328-
# save the VTK objects
328+
def _save_data(self):
329+
"""
330+
Save all the plot data as VTK files.
331+
"""
332+
329333
for tag, vtk in self.vtk_list:
330334
filename = self._get_filename(tag, "vtk")
331335
vtk.save(filename)
@@ -351,7 +355,7 @@ def open_pyvista(self, tag, data_window):
351355
# create the figure
352356
if self.plot_mode in ["nb_int", "nb_std"]:
353357
pl = self._get_plotter_pyvista_nb(notebook_size)
354-
elif self.plot_mode in ["save", "debug"]:
358+
elif self.plot_mode in ["png", "vtk", "debug"]:
355359
pl = self.__get_plotter_pyvista_base(image_size)
356360
elif self.plot_mode == "qt":
357361
pl = self._get_plotter_pyvista_qt(tag, show_menu, window_size)
@@ -377,7 +381,7 @@ def open_matplotlib(self, tag, data_window):
377381
# create the figure
378382
if self.plot_mode in ["nb_int", "nb_std"]:
379383
fig = self._get_figure_matplotlib_nb(notebook_size)
380-
elif self.plot_mode in ["save", "debug"]:
384+
elif self.plot_mode in ["png", "vtk", "debug"]:
381385
fig = self._get_figure_matplotlib_base(image_size)
382386
elif self.plot_mode == "qt":
383387
fig = self._get_figure_matplotlib_qt(tag, show_menu, window_size)
@@ -412,11 +416,16 @@ def show(self):
412416
LOGGER.debug("display notebook plots")
413417
self._show_figure_nb(False)
414418
LOGGER.debug("exit plotting routine")
415-
elif self.plot_mode == "save":
416-
LOGGER.debug("save and close all the plots")
419+
elif self.plot_mode == "png":
420+
LOGGER.debug("save PNG files")
417421
self._save_screenshot()
418422
self._close_figure()
419423
LOGGER.debug("exit plotting routine")
424+
elif self.plot_mode == "vtk":
425+
LOGGER.debug("save VTK files")
426+
self._save_data()
427+
self._close_figure()
428+
LOGGER.debug("exit plotting routine")
420429
elif self.plot_mode == "debug":
421430
LOGGER.debug("close all the plots")
422431
self._close_figure()

pypeec/main.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ def run_viewer_data(data_voxel, data_viewer, **kwargs):
109109
- The list describes plots to be shown.
110110
- If None or omitted: all the plots are shown.
111111
plot_mode : string
112-
- If "qt", the Qt framework is used for the rendering.
112+
- If "qt", the Qt framework is used for rendering the plots.
113113
- If "nb_int", interactive plots are rendered within the Jupyter notebook.
114114
- If "nb_std", static plots are rendered within the Jupyter notebook.
115-
- If "save", the plots are not shown but saved as PNG and VTK files.
115+
- If "png", the plot content are saved as PNG files.
116+
- If "vtk", the plot data are saved as VTK files.
116117
- If "debug", the plots are not shown (test mode).
117118
- If None or omitted: the debug mode is used.
118119
folder : string
@@ -158,10 +159,11 @@ def run_viewer_file(file_voxel, file_viewer, **kwargs):
158159
- The list describes plots to be shown.
159160
- If None or omitted: all the plots are shown.
160161
plot_mode : string
161-
- If "qt", the Qt framework is used for the rendering.
162+
- If "qt", the Qt framework is used for rendering the plots.
162163
- If "nb_int", interactive plots are rendered within the Jupyter notebook.
163164
- If "nb_std", static plots are rendered within the Jupyter notebook.
164-
- If "save", the plots are not shown but saved as PNG and VTK files.
165+
- If "png", the plot content are saved as PNG files.
166+
- If "vtk", the plot data are saved as VTK files.
165167
- If "debug", the plots are not shown (test mode).
166168
- If None or omitted: the debug mode is used.
167169
folder : string
@@ -295,10 +297,11 @@ def run_plotter_data(data_solution, data_plotter, **kwargs):
295297
- The list describes plots to be shown.
296298
- If None or omitted: all the plots are shown.
297299
plot_mode : string
298-
- If "qt", the Qt framework is used for the rendering.
300+
- If "qt", the Qt framework is used for rendering the plots.
299301
- If "nb_int", interactive plots are rendered within the Jupyter notebook.
300302
- If "nb_std", static plots are rendered within the Jupyter notebook.
301-
- If "save", the plots are not shown but saved as PNG and VTK files.
303+
- If "png", the plot content are saved as PNG files.
304+
- If "vtk", the plot data are saved as VTK files.
302305
- If "debug", the plots are not shown (test mode).
303306
- If None or omitted: the debug mode is used.
304307
folder : string
@@ -347,10 +350,11 @@ def run_plotter_file(file_solution, file_plotter, **kwargs):
347350
- The list describes plots to be shown.
348351
- If None or omitted: all the plots are shown.
349352
plot_mode : string
350-
- If "qt", the Qt framework is used for the rendering.
353+
- If "qt", the Qt framework is used for rendering the plots.
351354
- If "nb_int", interactive plots are rendered within the Jupyter notebook.
352355
- If "nb_std", static plots are rendered within the Jupyter notebook.
353-
- If "save", the plots are not shown but saved as PNG and VTK files.
356+
- If "png", the plot content are saved as PNG files.
357+
- If "vtk", the plot data are saved as VTK files.
354358
- If "debug", the plots are not shown (test mode).
355359
- If None or omitted: the debug mode is used.
356360
folder : string

pypeec/script.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def _get_arg_viewer(subparsers):
195195
"-pm",
196196
"--plot_mode",
197197
help="selection of the plot mode (default: window)",
198-
choices=["qt", "nb_int", "nb_std", "save", "debug"],
198+
choices=["qt", "nb_int", "nb_std", "png", "vtk", "debug"],
199199
default=None,
200200
dest="plot_mode",
201201
)
@@ -307,7 +307,7 @@ def _get_arg_plotter(subparsers):
307307
"-pm",
308308
"--plot_mode",
309309
help="selection of the plot mode (default: window)",
310-
choices=["qt", "nb_int", "nb_std", "save", "debug"],
310+
choices=["qt", "nb_int", "nb_std", "png", "vtk", "debug"],
311311
default=None,
312312
dest="plot_mode",
313313
)

0 commit comments

Comments
 (0)