Commit 64f82741323b39609d9196fb2b0f8a4bfec61548
1 parent
a1115f29
Exists in
master
and in
68 other branches
ENH: Visibility of surfaces generated by seeds using connectivity
Showing
3 changed files
with
75 additions
and
9 deletions
Show diff stats
invesalius/data/polydata_utils.py
| @@ -173,7 +173,9 @@ def SplitDisconectedParts(polydata): | @@ -173,7 +173,9 @@ def SplitDisconectedParts(polydata): | ||
| 173 | polydata_collection = [] | 173 | polydata_collection = [] |
| 174 | 174 | ||
| 175 | # Update progress value in GUI | 175 | # Update progress value in GUI |
| 176 | - UpdateProgress = vu.ShowProgress(nregions - 1) | 176 | + progress = nregions -1 |
| 177 | + if progress: | ||
| 178 | + UpdateProgress = vu.ShowProgress(progress) | ||
| 177 | 179 | ||
| 178 | for region in xrange(nregions): | 180 | for region in xrange(nregions): |
| 179 | conn.InitializeSpecifiedRegionList() | 181 | conn.InitializeSpecifiedRegionList() |
| @@ -185,6 +187,7 @@ def SplitDisconectedParts(polydata): | @@ -185,6 +187,7 @@ def SplitDisconectedParts(polydata): | ||
| 185 | p.Update() | 187 | p.Update() |
| 186 | 188 | ||
| 187 | polydata_collection.append(p) | 189 | polydata_collection.append(p) |
| 188 | - UpdateProgress(region, _("Splitting disconected parts")) | 190 | + if progress: |
| 191 | + UpdateProgress(region, _("Splitting disconected parts")) | ||
| 189 | 192 | ||
| 190 | return polydata_collection | 193 | return polydata_collection |
invesalius/data/surface.py
| @@ -126,6 +126,10 @@ class SurfaceManager(): | @@ -126,6 +126,10 @@ class SurfaceManager(): | ||
| 126 | ps.Publisher().subscribe(self.OnSeedSurface, "Create surface from seeds") | 126 | ps.Publisher().subscribe(self.OnSeedSurface, "Create surface from seeds") |
| 127 | 127 | ||
| 128 | def OnSeedSurface(self, pubsub_evt): | 128 | def OnSeedSurface(self, pubsub_evt): |
| 129 | + """ | ||
| 130 | + Create a new surface, based on the last selected surface, | ||
| 131 | + using as reference seeds user add to surface of reference. | ||
| 132 | + """ | ||
| 129 | points_id_list = pubsub_evt.data | 133 | points_id_list = pubsub_evt.data |
| 130 | index = self.last_surface_index | 134 | index = self.last_surface_index |
| 131 | proj = prj.Project() | 135 | proj = prj.Project() |
| @@ -133,27 +137,42 @@ class SurfaceManager(): | @@ -133,27 +137,42 @@ class SurfaceManager(): | ||
| 133 | 137 | ||
| 134 | new_polydata = pu.JoinSeedsParts(surface.polydata, | 138 | new_polydata = pu.JoinSeedsParts(surface.polydata, |
| 135 | points_id_list) | 139 | points_id_list) |
| 136 | - self.CreateSurfaceFromPolydata(new_polydata) | ||
| 137 | - self.ShowActor(index, False) | 140 | + index = self.CreateSurfaceFromPolydata(new_polydata) |
| 141 | + ps.Publisher().sendMessage('Show single surface', (index, True)) | ||
| 142 | + #self.ShowActor(index, True) | ||
| 143 | + | ||
| 138 | 144 | ||
| 139 | def OnSplitSurface(self, pubsub_evt): | 145 | def OnSplitSurface(self, pubsub_evt): |
| 146 | + """ | ||
| 147 | + Create n new surfaces, based on the last selected surface, | ||
| 148 | + according to their connectivity. | ||
| 149 | + """ | ||
| 140 | index = self.last_surface_index | 150 | index = self.last_surface_index |
| 141 | proj = prj.Project() | 151 | proj = prj.Project() |
| 142 | surface = proj.surface_dict[index] | 152 | surface = proj.surface_dict[index] |
| 143 | 153 | ||
| 154 | + index_list = [] | ||
| 144 | new_polydata_list = pu.SplitDisconectedParts(surface.polydata) | 155 | new_polydata_list = pu.SplitDisconectedParts(surface.polydata) |
| 145 | for polydata in new_polydata_list: | 156 | for polydata in new_polydata_list: |
| 146 | - self.CreateSurfaceFromPolydata(polydata) | ||
| 147 | - self.ShowActor(index, False) | 157 | + index = self.CreateSurfaceFromPolydata(polydata) |
| 158 | + index_list.append(index) | ||
| 159 | + #self.ShowActor(index, True) | ||
| 160 | + | ||
| 161 | + ps.Publisher().sendMessage('Show multiple surfaces', (index_list, True)) | ||
| 162 | + | ||
| 148 | 163 | ||
| 149 | def OnLargestSurface(self, pubsub_evt): | 164 | def OnLargestSurface(self, pubsub_evt): |
| 165 | + """ | ||
| 166 | + Create a new surface, based on largest part of the last | ||
| 167 | + selected surface. | ||
| 168 | + """ | ||
| 150 | index = self.last_surface_index | 169 | index = self.last_surface_index |
| 151 | proj = prj.Project() | 170 | proj = prj.Project() |
| 152 | surface = proj.surface_dict[index] | 171 | surface = proj.surface_dict[index] |
| 153 | 172 | ||
| 154 | new_polydata = pu.SelectLargestPart(surface.polydata) | 173 | new_polydata = pu.SelectLargestPart(surface.polydata) |
| 155 | - self.CreateSurfaceFromPolydata(new_polydata) | ||
| 156 | - self.ShowActor(index, False) | 174 | + new_index = self.CreateSurfaceFromPolydata(new_polydata) |
| 175 | + ps.Publisher().sendMessage('Show single surface', (new_index, True)) | ||
| 157 | 176 | ||
| 158 | def CreateSurfaceFromPolydata(self, polydata, overwrite=False): | 177 | def CreateSurfaceFromPolydata(self, polydata, overwrite=False): |
| 159 | 178 | ||
| @@ -208,6 +227,8 @@ class SurfaceManager(): | @@ -208,6 +227,8 @@ class SurfaceManager(): | ||
| 208 | surface.colour, surface.volume, | 227 | surface.colour, surface.volume, |
| 209 | surface.transparency)) | 228 | surface.transparency)) |
| 210 | 229 | ||
| 230 | + return surface.index | ||
| 231 | + | ||
| 211 | 232 | ||
| 212 | def OnCloseProject(self, pubsub_evt): | 233 | def OnCloseProject(self, pubsub_evt): |
| 213 | self.CloseProject() | 234 | self.CloseProject() |
| @@ -481,7 +502,6 @@ class SurfaceManager(): | @@ -481,7 +502,6 @@ class SurfaceManager(): | ||
| 481 | 502 | ||
| 482 | def OnShowSurface(self, pubsub_evt): | 503 | def OnShowSurface(self, pubsub_evt): |
| 483 | index, value = pubsub_evt.data | 504 | index, value = pubsub_evt.data |
| 484 | - #print "OnShowSurface", index, value | ||
| 485 | self.ShowActor(index, value) | 505 | self.ShowActor(index, value) |
| 486 | 506 | ||
| 487 | def ShowActor(self, index, value): | 507 | def ShowActor(self, index, value): |
invesalius/gui/data_notebook.py
| @@ -341,6 +341,11 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -341,6 +341,11 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 341 | if i > index: | 341 | if i > index: |
| 342 | new_dict[i-1] = old_dict[i] | 342 | new_dict[i-1] = old_dict[i] |
| 343 | self.mask_list_index = new_dict | 343 | self.mask_list_index = new_dict |
| 344 | + | ||
| 345 | + if new_dict: | ||
| 346 | + self.SetItemImage(0, 1) | ||
| 347 | + ps.Publisher().sendMessage('Show mask', (0, 1)) | ||
| 348 | + | ||
| 344 | self.DeleteItem(index) | 349 | self.DeleteItem(index) |
| 345 | 350 | ||
| 346 | #------------------------------------------------- | 351 | #------------------------------------------------- |
| @@ -372,6 +377,10 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -372,6 +377,10 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 372 | 'Set surface colour') | 377 | 'Set surface colour') |
| 373 | ps.Publisher().subscribe(self.OnCloseProject, 'Close project data') | 378 | ps.Publisher().subscribe(self.OnCloseProject, 'Close project data') |
| 374 | 379 | ||
| 380 | + | ||
| 381 | + ps.Publisher().subscribe(self.OnShowSingle, 'Show single surface') | ||
| 382 | + ps.Publisher().subscribe(self.OnShowMultiple, 'Show multiple surfaces') | ||
| 383 | + | ||
| 375 | def __bind_events_wx(self): | 384 | def __bind_events_wx(self): |
| 376 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) | 385 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) |
| 377 | self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEditLabel) | 386 | self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEditLabel) |
| @@ -436,6 +445,40 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -436,6 +445,40 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 436 | def OnCheckItem(self, index, flag): | 445 | def OnCheckItem(self, index, flag): |
| 437 | ps.Publisher().sendMessage('Show surface', (index, flag)) | 446 | ps.Publisher().sendMessage('Show surface', (index, flag)) |
| 438 | 447 | ||
| 448 | + def OnShowSingle(self, pubsub_evt): | ||
| 449 | + index, visibility = pubsub_evt.data | ||
| 450 | + print "----------------------" | ||
| 451 | + print "OnShowSingle" | ||
| 452 | + print "index", index | ||
| 453 | + print "visibility", visibility | ||
| 454 | + print "----------------------" | ||
| 455 | + for key in self.surface_list_index.keys(): | ||
| 456 | + if key != index: | ||
| 457 | + self.SetItemImage(key, not visibility) | ||
| 458 | + ps.Publisher().sendMessage('Show surface', | ||
| 459 | + (key, not visibility)) | ||
| 460 | + self.SetItemImage(index, visibility) | ||
| 461 | + ps.Publisher().sendMessage('Show surface', | ||
| 462 | + (index, visibility)) | ||
| 463 | + | ||
| 464 | + def OnShowMultiple(self, pubsub_evt): | ||
| 465 | + index_list, visibility = pubsub_evt.data | ||
| 466 | + print "----------------------" | ||
| 467 | + print "OnShowMultiple" | ||
| 468 | + print "index", index_list | ||
| 469 | + print "visibility", visibility | ||
| 470 | + print "----------------------" | ||
| 471 | + | ||
| 472 | + for key in self.surface_list_index.keys(): | ||
| 473 | + if key not in index_list: | ||
| 474 | + self.SetItemImage(key, not visibility) | ||
| 475 | + ps.Publisher().sendMessage('Show surface', | ||
| 476 | + (key, not visibility)) | ||
| 477 | + for index in index_list: | ||
| 478 | + self.SetItemImage(index, visibility) | ||
| 479 | + ps.Publisher().sendMessage('Show surface', | ||
| 480 | + (index, visibility)) | ||
| 481 | + | ||
| 439 | def AddSurface(self, pubsub_evt): | 482 | def AddSurface(self, pubsub_evt): |
| 440 | 483 | ||
| 441 | 484 |