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 | 284 | |
285 | 285 | def OnExportSurface(self, pubsub_evt): |
286 | 286 | filename, filetype = pubsub_evt.data |
287 | - | |
288 | 287 | if filetype == const.FILETYPE_STL: |
289 | 288 | proj = prj.Project() |
290 | 289 | polydata_list = [] |
... | ... | @@ -292,13 +291,14 @@ class SurfaceManager(): |
292 | 291 | surface = proj.surface_dict[index] |
293 | 292 | if surface.is_shown: |
294 | 293 | polydata_list.append(surface.polydata) |
295 | - if len(polydata_list) < 0: | |
294 | + if len(polydata_list) == 0: | |
296 | 295 | print "oops - no polydata" |
297 | 296 | return |
298 | 297 | elif len(polydata_list) == 1: |
299 | 298 | polydata = polydata_list[0] |
300 | 299 | else: |
301 | 300 | polydata = pu.Merge(polydata_list) |
301 | + | |
302 | 302 | writer = vtk.vtkSTLWriter() |
303 | 303 | writer.SetFileTypeToBinary() |
304 | 304 | writer.SetFileName(filename) | ... | ... |
invesalius/gui/task_exporter.py
... | ... | @@ -156,7 +156,7 @@ class InnerTaskPanel(wx.Panel): |
156 | 156 | flag_link = wx.EXPAND|wx.GROW|wx.LEFT|wx.TOP |
157 | 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 | 160 | fixed_sizer.AddGrowableCol(0, 1) |
161 | 161 | fixed_sizer.AddMany([ (link_export_picture, 1, flag_link, 3), |
162 | 162 | (button_picture, 0, flag_button), |
... | ... | @@ -182,16 +182,22 @@ class InnerTaskPanel(wx.Panel): |
182 | 182 | |
183 | 183 | def OnLinkExportSurface(self, evt=None): |
184 | 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 | 198 | dlg = wx.FileDialog(None, |
193 | - "Export 3D surface", # title | |
194 | - "", # directory | |
199 | + "Save 3D surface as...", # title | |
200 | + "", # last used directory | |
195 | 201 | project_name, # filename |
196 | 202 | WILDCARD_SAVE_3D, |
197 | 203 | wx.SAVE|wx.OVERWRITE_PROMPT) |
... | ... | @@ -208,7 +214,14 @@ class InnerTaskPanel(wx.Panel): |
208 | 214 | ps.Publisher().sendMessage('Export surface to file', |
209 | 215 | (filename, filetype)) |
210 | 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 | 226 | def OnLinkRequestRP(self, evt=None): |
214 | 227 | pass | ... | ... |