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