Commit bf066ca01e65cfc76d22a4a3ae1de8a0c34da437
1 parent
f9d49cf7
Exists in
master
and in
68 other branches
ENC: Minor fixes related to export surface.
Showing
2 changed files
with
24 additions
and
11 deletions
Show diff stats
invesalius/data/surface.py
@@ -284,7 +284,6 @@ class SurfaceManager(): | @@ -284,7 +284,6 @@ class SurfaceManager(): | ||
284 | 284 | ||
285 | def OnExportSurface(self, pubsub_evt): | 285 | def OnExportSurface(self, pubsub_evt): |
286 | filename, filetype = pubsub_evt.data | 286 | filename, filetype = pubsub_evt.data |
287 | - | ||
288 | if filetype == const.FILETYPE_STL: | 287 | if filetype == const.FILETYPE_STL: |
289 | proj = prj.Project() | 288 | proj = prj.Project() |
290 | polydata_list = [] | 289 | polydata_list = [] |
@@ -292,13 +291,14 @@ class SurfaceManager(): | @@ -292,13 +291,14 @@ class SurfaceManager(): | ||
292 | surface = proj.surface_dict[index] | 291 | surface = proj.surface_dict[index] |
293 | if surface.is_shown: | 292 | if surface.is_shown: |
294 | polydata_list.append(surface.polydata) | 293 | polydata_list.append(surface.polydata) |
295 | - if len(polydata_list) < 0: | 294 | + if len(polydata_list) == 0: |
296 | print "oops - no polydata" | 295 | print "oops - no polydata" |
297 | return | 296 | return |
298 | elif len(polydata_list) == 1: | 297 | elif len(polydata_list) == 1: |
299 | polydata = polydata_list[0] | 298 | polydata = polydata_list[0] |
300 | else: | 299 | else: |
301 | polydata = pu.Merge(polydata_list) | 300 | polydata = pu.Merge(polydata_list) |
301 | + | ||
302 | writer = vtk.vtkSTLWriter() | 302 | writer = vtk.vtkSTLWriter() |
303 | writer.SetFileTypeToBinary() | 303 | writer.SetFileTypeToBinary() |
304 | writer.SetFileName(filename) | 304 | writer.SetFileName(filename) |
invesalius/gui/task_exporter.py
@@ -156,7 +156,7 @@ class InnerTaskPanel(wx.Panel): | @@ -156,7 +156,7 @@ class InnerTaskPanel(wx.Panel): | ||
156 | flag_link = wx.EXPAND|wx.GROW|wx.LEFT|wx.TOP | 156 | flag_link = wx.EXPAND|wx.GROW|wx.LEFT|wx.TOP |
157 | flag_button = wx.EXPAND | wx.GROW | 157 | flag_button = wx.EXPAND | wx.GROW |
158 | 158 | ||
159 | - fixed_sizer = wx.FlexGridSizer(rows=3, cols=2, hgap=2, vgap=0) | 159 | + fixed_sizer = wx.FlexGridSizer(rows=4, cols=2, hgap=2, vgap=0) |
160 | fixed_sizer.AddGrowableCol(0, 1) | 160 | fixed_sizer.AddGrowableCol(0, 1) |
161 | fixed_sizer.AddMany([ (link_export_picture, 1, flag_link, 3), | 161 | fixed_sizer.AddMany([ (link_export_picture, 1, flag_link, 3), |
162 | (button_picture, 0, flag_button), | 162 | (button_picture, 0, flag_button), |
@@ -182,16 +182,22 @@ class InnerTaskPanel(wx.Panel): | @@ -182,16 +182,22 @@ class InnerTaskPanel(wx.Panel): | ||
182 | 182 | ||
183 | def OnLinkExportSurface(self, evt=None): | 183 | def OnLinkExportSurface(self, evt=None): |
184 | project = proj.Project() | 184 | project = proj.Project() |
185 | - if sys.platform == 'win32': | ||
186 | - project_name = project.name | ||
187 | - else: | ||
188 | - project_name = project.name+".stl" | 185 | + n_surface = 0 |
186 | + | ||
187 | + for index in project.surface_dict: | ||
188 | + if project.surface_dict[index].is_shown: | ||
189 | + n_surface += 1 | ||
190 | + | ||
191 | + if n_surface: | ||
192 | + if sys.platform == 'win32': | ||
193 | + project_name = project.name | ||
194 | + else: | ||
195 | + project_name = project.name+".stl" | ||
189 | 196 | ||
190 | - if project.surface_dict: | ||
191 | 197 | ||
192 | dlg = wx.FileDialog(None, | 198 | dlg = wx.FileDialog(None, |
193 | - "Export 3D surface", # title | ||
194 | - "", # directory | 199 | + "Save 3D surface as...", # title |
200 | + "", # last used directory | ||
195 | project_name, # filename | 201 | project_name, # filename |
196 | WILDCARD_SAVE_3D, | 202 | WILDCARD_SAVE_3D, |
197 | wx.SAVE|wx.OVERWRITE_PROMPT) | 203 | wx.SAVE|wx.OVERWRITE_PROMPT) |
@@ -208,7 +214,14 @@ class InnerTaskPanel(wx.Panel): | @@ -208,7 +214,14 @@ class InnerTaskPanel(wx.Panel): | ||
208 | ps.Publisher().sendMessage('Export surface to file', | 214 | ps.Publisher().sendMessage('Export surface to file', |
209 | (filename, filetype)) | 215 | (filename, filetype)) |
210 | else: | 216 | else: |
211 | - print "Nao tem superficie, nao podemos exportar" | 217 | + dlg = wx.MessageDialog(None, |
218 | + "Create a surface and make it visible in order to export it.", | ||
219 | + 'InVesalius 3 - Warning', | ||
220 | + wx.OK | wx.ICON_INFORMATION) | ||
221 | + try: | ||
222 | + dlg.ShowModal() | ||
223 | + finally: | ||
224 | + dlg.Destroy() | ||
212 | 225 | ||
213 | def OnLinkRequestRP(self, evt=None): | 226 | def OnLinkRequestRP(self, evt=None): |
214 | pass | 227 | pass |