Commit 930822b3cff4b394dffb6068590733e7cc98c441
1 parent
b0985764
Exists in
master
and in
68 other branches
FIX: the filename pattern in export images
Showing
4 changed files
with
45 additions
and
51 deletions
Show diff stats
invesalius/data/viewer_slice.py
| ... | ... | @@ -865,36 +865,34 @@ class Viewer(wx.Panel): |
| 865 | 865 | writer.SetFilePrefix(filename.split(".")[0]) |
| 866 | 866 | writer.SetRenderWindow(renwin) |
| 867 | 867 | writer.Write() |
| 868 | - return | |
| 869 | 868 | else: |
| 870 | 869 | #Use tiling to generate a large rendering. |
| 871 | 870 | image = vtk.vtkRenderLargeImage() |
| 872 | 871 | image.SetInput(self.ren) |
| 873 | 872 | image.SetMagnification(2) |
| 874 | 873 | |
| 875 | - image = image.GetOutput() | |
| 876 | - | |
| 877 | - | |
| 878 | - # write image file | |
| 879 | - if (filetype == const.FILETYPE_BMP): | |
| 880 | - writer = vtk.vtkBMPWriter() | |
| 881 | - elif (filetype == const.FILETYPE_JPG): | |
| 882 | - writer = vtk.vtkJPEGWriter() | |
| 883 | - elif (filetype == const.FILETYPE_PNG): | |
| 884 | - writer = vtk.vtkPNGWriter() | |
| 885 | - elif (filetype == const.FILETYPE_PS): | |
| 886 | - writer = vtk.vtkPostScriptWriter() | |
| 887 | - elif (filetype == const.FILETYPE_TIF): | |
| 888 | - writer = vtk.vtkTIFFWriter() | |
| 889 | - filename = "%s.tif"%filename.strip(".tif") | |
| 890 | - | |
| 891 | - writer.SetInput(image) | |
| 892 | - writer.SetFileName(filename) | |
| 893 | - writer.Write() | |
| 894 | - | |
| 895 | - for actor in view_prop_list: | |
| 896 | - self.ren.AddViewProp(actor) | |
| 874 | + image = image.GetOutput() | |
| 875 | + | |
| 876 | + | |
| 877 | + # write image file | |
| 878 | + if (filetype == const.FILETYPE_BMP): | |
| 879 | + writer = vtk.vtkBMPWriter() | |
| 880 | + elif (filetype == const.FILETYPE_JPG): | |
| 881 | + writer = vtk.vtkJPEGWriter() | |
| 882 | + elif (filetype == const.FILETYPE_PNG): | |
| 883 | + writer = vtk.vtkPNGWriter() | |
| 884 | + elif (filetype == const.FILETYPE_PS): | |
| 885 | + writer = vtk.vtkPostScriptWriter() | |
| 886 | + elif (filetype == const.FILETYPE_TIF): | |
| 887 | + writer = vtk.vtkTIFFWriter() | |
| 888 | + filename = "%s.tif"%filename.strip(".tif") | |
| 889 | + | |
| 890 | + writer.SetInput(image) | |
| 891 | + writer.SetFileName(filename) | |
| 892 | + writer.Write() | |
| 897 | 893 | |
| 894 | + for actor in view_prop_list: | |
| 895 | + self.ren.AddViewProp(actor) | |
| 898 | 896 | |
| 899 | 897 | ps.Publisher().sendMessage('End busy cursor') |
| 900 | 898 | ... | ... |
invesalius/data/viewer_volume.py
| ... | ... | @@ -159,35 +159,34 @@ class Viewer(wx.Panel): |
| 159 | 159 | image = vtk.vtkWindowToImageFilter() |
| 160 | 160 | image.SetInput(renwin) |
| 161 | 161 | writer = vtk.vtkPOVExporter() |
| 162 | - writer.SetFilePrefix(filename.split(".")[0]) | |
| 162 | + writer.SetFileName(filename) | |
| 163 | 163 | writer.SetRenderWindow(renwin) |
| 164 | 164 | writer.Write() |
| 165 | - return | |
| 166 | 165 | else: |
| 167 | 166 | #Use tiling to generate a large rendering. |
| 168 | 167 | image = vtk.vtkRenderLargeImage() |
| 169 | 168 | image.SetInput(self.ren) |
| 170 | 169 | image.SetMagnification(2) |
| 171 | 170 | |
| 172 | - image = image.GetOutput() | |
| 173 | - | |
| 174 | - | |
| 175 | - # write image file | |
| 176 | - if (filetype == const.FILETYPE_BMP): | |
| 177 | - writer = vtk.vtkBMPWriter() | |
| 178 | - elif (filetype == const.FILETYPE_JPG): | |
| 179 | - writer = vtk.vtkJPEGWriter() | |
| 180 | - elif (filetype == const.FILETYPE_PNG): | |
| 181 | - writer = vtk.vtkPNGWriter() | |
| 182 | - elif (filetype == const.FILETYPE_PS): | |
| 183 | - writer = vtk.vtkPostScriptWriter() | |
| 184 | - elif (filetype == const.FILETYPE_TIF): | |
| 185 | - writer = vtk.vtkTIFFWriter() | |
| 186 | - filename = "%s.tif"%filename.strip(".tif") | |
| 187 | - | |
| 188 | - writer.SetInput(image) | |
| 189 | - writer.SetFileName(filename) | |
| 190 | - writer.Write() | |
| 171 | + image = image.GetOutput() | |
| 172 | + | |
| 173 | + | |
| 174 | + # write image file | |
| 175 | + if (filetype == const.FILETYPE_BMP): | |
| 176 | + writer = vtk.vtkBMPWriter() | |
| 177 | + elif (filetype == const.FILETYPE_JPG): | |
| 178 | + writer = vtk.vtkJPEGWriter() | |
| 179 | + elif (filetype == const.FILETYPE_PNG): | |
| 180 | + writer = vtk.vtkPNGWriter() | |
| 181 | + elif (filetype == const.FILETYPE_PS): | |
| 182 | + writer = vtk.vtkPostScriptWriter() | |
| 183 | + elif (filetype == const.FILETYPE_TIF): | |
| 184 | + writer = vtk.vtkTIFFWriter() | |
| 185 | + filename = "%s.tif"%filename.strip(".tif") | |
| 186 | + | |
| 187 | + writer.SetInput(image) | |
| 188 | + writer.SetFileName(filename) | |
| 189 | + writer.Write() | |
| 191 | 190 | ps.Publisher().sendMessage('End busy cursor') |
| 192 | 191 | |
| 193 | 192 | ... | ... |
invesalius/gui/dialogs.py
| ... | ... | @@ -537,16 +537,14 @@ def ExportPicture(type_=""): |
| 537 | 537 | utils.debug("ExportPicture") |
| 538 | 538 | project = proj.Project() |
| 539 | 539 | |
| 540 | - if sys.platform == 'win32': | |
| 541 | - project_name = project.name | |
| 542 | - else: | |
| 543 | - project_name = project.name+".jpg" | |
| 544 | - | |
| 540 | + project_name = "%s_%s" % (project.name, type_) | |
| 541 | + if not sys.platform in ('win32', 'linux2'): | |
| 542 | + project_name += ".jpg" | |
| 545 | 543 | |
| 546 | 544 | dlg = wx.FileDialog(None, |
| 547 | 545 | "Save %s picture as..." %type_, |
| 548 | 546 | "", # last used directory |
| 549 | - "%s_%s"%(project_name, type_), # filename | |
| 547 | + project_name, # filename | |
| 550 | 548 | WILDCARD_SAVE_PICTURE, |
| 551 | 549 | wx.SAVE|wx.OVERWRITE_PROMPT) |
| 552 | 550 | dlg.SetFilterIndex(1) # default is VTI | ... | ... |
invesalius/gui/task_exporter.py
| ... | ... | @@ -247,7 +247,6 @@ class InnerTaskPanel(wx.Panel): |
| 247 | 247 | value = dlg.ExportPicture(self.id_to_name[id]) |
| 248 | 248 | if value: |
| 249 | 249 | filename, filetype = value |
| 250 | - print filename, filetype | |
| 251 | 250 | ps.Publisher().sendMessage('Export picture to file', |
| 252 | 251 | (id, filename, filetype)) |
| 253 | 252 | ... | ... |