Commit c056c6c597147c87732043e9f958c2c04fac7710
1 parent
0158ec5b
Exists in
master
and in
68 other branches
ENH: General improvements on surface manipulation
Showing
4 changed files
with
13 additions
and
25 deletions
Show diff stats
invesalius/data/polydata_utils.py
@@ -158,7 +158,8 @@ def SplitDisconectedParts(polydata): | @@ -158,7 +158,8 @@ def SplitDisconectedParts(polydata): | ||
158 | nregions = conn.GetNumberOfExtractedRegions() | 158 | nregions = conn.GetNumberOfExtractedRegions() |
159 | 159 | ||
160 | polydata_collection = [] | 160 | polydata_collection = [] |
161 | - | 161 | + |
162 | + | ||
162 | for region in xrange(nregions): | 163 | for region in xrange(nregions): |
163 | conn.InitializeSpecifiedRegionList() | 164 | conn.InitializeSpecifiedRegionList() |
164 | conn.AddSpecifiedRegion(region) | 165 | conn.AddSpecifiedRegion(region) |
invesalius/data/surface.py
@@ -126,7 +126,7 @@ class SurfaceManager(): | @@ -126,7 +126,7 @@ 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 | - index, points_id_list = pubsub_evt.data | 129 | + points_id_list = pubsub_evt.data |
130 | index = self.last_surface_index | 130 | index = self.last_surface_index |
131 | proj = prj.Project() | 131 | proj = prj.Project() |
132 | surface = proj.surface_dict[index] | 132 | surface = proj.surface_dict[index] |
@@ -134,9 +134,9 @@ class SurfaceManager(): | @@ -134,9 +134,9 @@ class SurfaceManager(): | ||
134 | new_polydata = pu.JoinSeedsParts(surface.polydata, | 134 | new_polydata = pu.JoinSeedsParts(surface.polydata, |
135 | points_id_list) | 135 | points_id_list) |
136 | self.CreateSurfaceFromPolydata(new_polydata) | 136 | self.CreateSurfaceFromPolydata(new_polydata) |
137 | + self.ShowActor(index, False) | ||
137 | 138 | ||
138 | def OnSplitSurface(self, pubsub_evt): | 139 | def OnSplitSurface(self, pubsub_evt): |
139 | - index = pubsub_evt.data | ||
140 | index = self.last_surface_index | 140 | index = self.last_surface_index |
141 | proj = prj.Project() | 141 | proj = prj.Project() |
142 | surface = proj.surface_dict[index] | 142 | surface = proj.surface_dict[index] |
@@ -144,16 +144,16 @@ class SurfaceManager(): | @@ -144,16 +144,16 @@ class SurfaceManager(): | ||
144 | new_polydata_list = pu.SplitDisconectedParts(surface.polydata) | 144 | new_polydata_list = pu.SplitDisconectedParts(surface.polydata) |
145 | for polydata in new_polydata_list: | 145 | for polydata in new_polydata_list: |
146 | self.CreateSurfaceFromPolydata(polydata) | 146 | self.CreateSurfaceFromPolydata(polydata) |
147 | + self.ShowActor(index, False) | ||
147 | 148 | ||
148 | def OnLargestSurface(self, pubsub_evt): | 149 | def OnLargestSurface(self, pubsub_evt): |
149 | - index = pubsub_evt.data | ||
150 | index = self.last_surface_index | 150 | index = self.last_surface_index |
151 | proj = prj.Project() | 151 | proj = prj.Project() |
152 | surface = proj.surface_dict[index] | 152 | surface = proj.surface_dict[index] |
153 | 153 | ||
154 | new_polydata = pu.SelectLargestPart(surface.polydata) | 154 | new_polydata = pu.SelectLargestPart(surface.polydata) |
155 | self.CreateSurfaceFromPolydata(new_polydata) | 155 | self.CreateSurfaceFromPolydata(new_polydata) |
156 | - #TODO: Hide previous | 156 | + self.ShowActor(index, False) |
157 | 157 | ||
158 | def CreateSurfaceFromPolydata(self, polydata, overwrite=False): | 158 | def CreateSurfaceFromPolydata(self, polydata, overwrite=False): |
159 | mapper = vtk.vtkPolyDataMapper() | 159 | mapper = vtk.vtkPolyDataMapper() |
@@ -224,7 +224,7 @@ class SurfaceManager(): | @@ -224,7 +224,7 @@ class SurfaceManager(): | ||
224 | surface.colour, surface.volume, | 224 | surface.colour, surface.volume, |
225 | surface.transparency)) | 225 | surface.transparency)) |
226 | self.last_surface_index = index | 226 | self.last_surface_index = index |
227 | - | 227 | + self.ShowActor(index, True) |
228 | 228 | ||
229 | 229 | ||
230 | 230 |
invesalius/data/viewer_volume.py
@@ -86,7 +86,6 @@ class Viewer(wx.Panel): | @@ -86,7 +86,6 @@ class Viewer(wx.Panel): | ||
86 | self.picker = vtk.vtkPointPicker() | 86 | self.picker = vtk.vtkPointPicker() |
87 | interactor.SetPicker(self.picker) | 87 | interactor.SetPicker(self.picker) |
88 | self.seed_points = [] | 88 | self.seed_points = [] |
89 | - self.current_surface_index = 0 | ||
90 | 89 | ||
91 | 90 | ||
92 | def __bind_events(self): | 91 | def __bind_events(self): |
@@ -143,13 +142,11 @@ class Viewer(wx.Panel): | @@ -143,13 +142,11 @@ class Viewer(wx.Panel): | ||
143 | 142 | ||
144 | def OnStartSeed(self, pubsub_evt): | 143 | def OnStartSeed(self, pubsub_evt): |
145 | index = pubsub_evt.data | 144 | index = pubsub_evt.data |
146 | - self.current_surface_index = index | ||
147 | self.seed_points = [] | 145 | self.seed_points = [] |
148 | 146 | ||
149 | def OnEndSeed(self, pubsub_evt): | 147 | def OnEndSeed(self, pubsub_evt): |
150 | ps.Publisher().sendMessage("Create surface from seeds", | 148 | ps.Publisher().sendMessage("Create surface from seeds", |
151 | - (self.current_surface_index , | ||
152 | - self.seed_points)) | 149 | + self.seed_points) |
153 | 150 | ||
154 | 151 | ||
155 | def OnExportPicture(self, pubsub_evt): | 152 | def OnExportPicture(self, pubsub_evt): |
invesalius/gui/task_surface.py
@@ -197,18 +197,15 @@ class InnerFoldPanel(wx.Panel): | @@ -197,18 +197,15 @@ class InnerFoldPanel(wx.Panel): | ||
197 | 197 | ||
198 | # Fold 1 - Surface properties | 198 | # Fold 1 - Surface properties |
199 | item = fold_panel.AddFoldPanel(_("Surface properties"), collapsed=True) | 199 | item = fold_panel.AddFoldPanel(_("Surface properties"), collapsed=True) |
200 | - self.surface_properties = SurfaceProperties(item) | ||
201 | fold_panel.ApplyCaptionStyle(item, style) | 200 | fold_panel.ApplyCaptionStyle(item, style) |
202 | - fold_panel.AddFoldPanelWindow(item, self.surface_properties, Spacing= 0, | 201 | + fold_panel.AddFoldPanelWindow(item, SurfaceProperties(item), Spacing= 0, |
203 | leftSpacing=0, rightSpacing=0) | 202 | leftSpacing=0, rightSpacing=0) |
204 | fold_panel.Expand(fold_panel.GetFoldPanel(0)) | 203 | fold_panel.Expand(fold_panel.GetFoldPanel(0)) |
205 | 204 | ||
206 | # Fold 2 - Surface tools | 205 | # Fold 2 - Surface tools |
207 | item = fold_panel.AddFoldPanel(_("Advanced options"), collapsed=True) | 206 | item = fold_panel.AddFoldPanel(_("Advanced options"), collapsed=True) |
208 | fold_panel.ApplyCaptionStyle(item, style) | 207 | fold_panel.ApplyCaptionStyle(item, style) |
209 | - self.surface_tools = SurfaceTools(item) | ||
210 | - self.surface_tools.combo_surface_name = self.surface_properties.combo_surface_name | ||
211 | - fold_panel.AddFoldPanelWindow(item, self.surface_tools, Spacing= 0, | 208 | + fold_panel.AddFoldPanelWindow(item, SurfaceTools(item), Spacing= 0, |
212 | leftSpacing=0, rightSpacing=0) | 209 | leftSpacing=0, rightSpacing=0) |
213 | 210 | ||
214 | #fold_panel.AddFoldPanelWindow(item, QualityAdjustment(item), Spacing= 0, | 211 | #fold_panel.AddFoldPanelWindow(item, QualityAdjustment(item), Spacing= 0, |
@@ -236,7 +233,6 @@ class SurfaceTools(wx.Panel): | @@ -236,7 +233,6 @@ class SurfaceTools(wx.Panel): | ||
236 | #self.SetBackgroundColour(wx.Colour(255,255,255)) | 233 | #self.SetBackgroundColour(wx.Colour(255,255,255)) |
237 | self.SetAutoLayout(1) | 234 | self.SetAutoLayout(1) |
238 | 235 | ||
239 | - self.combo_surface_name = None | ||
240 | 236 | ||
241 | # Fixed hyperlink items | 237 | # Fixed hyperlink items |
242 | tooltip = wx.ToolTip(_("Automatically select largest disconnect surface")) | 238 | tooltip = wx.ToolTip(_("Automatically select largest disconnect surface")) |
@@ -336,15 +332,11 @@ class SurfaceTools(wx.Panel): | @@ -336,15 +332,11 @@ class SurfaceTools(wx.Panel): | ||
336 | self.SelectSeed() | 332 | self.SelectSeed() |
337 | 333 | ||
338 | def SelectLargest(self): | 334 | def SelectLargest(self): |
339 | - index = self.combo_surface_name.GetSelection() | ||
340 | - ps.Publisher().sendMessage('Create surface from largest region', index) | 335 | + ps.Publisher().sendMessage('Create surface from largest region') |
341 | 336 | ||
342 | def SplitSurface(self): | 337 | def SplitSurface(self): |
343 | - index = self.combo_surface_name.GetSelection() | ||
344 | - ps.Publisher().sendMessage('Split surface', index) | 338 | + ps.Publisher().sendMessage('Split surface') |
345 | 339 | ||
346 | - # surface_manager | ||
347 | - | ||
348 | def SelectSeed(self): | 340 | def SelectSeed(self): |
349 | if self.button_seeds.IsPressed(): | 341 | if self.button_seeds.IsPressed(): |
350 | self.StartSeeding() | 342 | self.StartSeeding() |
@@ -352,14 +344,12 @@ class SurfaceTools(wx.Panel): | @@ -352,14 +344,12 @@ class SurfaceTools(wx.Panel): | ||
352 | self.EndSeeding() | 344 | self.EndSeeding() |
353 | 345 | ||
354 | def StartSeeding(self): | 346 | def StartSeeding(self): |
355 | - index = self.combo_surface_name.GetSelection() | ||
356 | ps.Publisher().sendMessage('Enable style', const.VOLUME_STATE_SEED) | 347 | ps.Publisher().sendMessage('Enable style', const.VOLUME_STATE_SEED) |
357 | - ps.Publisher().sendMessage('Create surface by seeding - start', index) | 348 | + ps.Publisher().sendMessage('Create surface by seeding - start') |
358 | 349 | ||
359 | def EndSeeding(self): | 350 | def EndSeeding(self): |
360 | ps.Publisher().sendMessage('Disable style', const.VOLUME_STATE_SEED) | 351 | ps.Publisher().sendMessage('Disable style', const.VOLUME_STATE_SEED) |
361 | ps.Publisher().sendMessage('Create surface by seeding - end') | 352 | ps.Publisher().sendMessage('Create surface by seeding - end') |
362 | - # volume_viewer -> surface_manager | ||
363 | 353 | ||
364 | 354 | ||
365 | 355 |