Commit 0158ec5bee055134c74258b561b601b5f489ca5c
1 parent
1582c8e8
Exists in
master
and in
68 other branches
ADD: Surface connectivity tools
Showing
3 changed files
with
15 additions
and
5 deletions
Show diff stats
invesalius/data/polydata_utils.py
invesalius/data/surface.py
... | ... | @@ -127,6 +127,7 @@ class SurfaceManager(): |
127 | 127 | |
128 | 128 | def OnSeedSurface(self, pubsub_evt): |
129 | 129 | index, points_id_list = pubsub_evt.data |
130 | + index = self.last_surface_index | |
130 | 131 | proj = prj.Project() |
131 | 132 | surface = proj.surface_dict[index] |
132 | 133 | |
... | ... | @@ -136,6 +137,7 @@ class SurfaceManager(): |
136 | 137 | |
137 | 138 | def OnSplitSurface(self, pubsub_evt): |
138 | 139 | index = pubsub_evt.data |
140 | + index = self.last_surface_index | |
139 | 141 | proj = prj.Project() |
140 | 142 | surface = proj.surface_dict[index] |
141 | 143 | |
... | ... | @@ -145,11 +147,13 @@ class SurfaceManager(): |
145 | 147 | |
146 | 148 | def OnLargestSurface(self, pubsub_evt): |
147 | 149 | index = pubsub_evt.data |
150 | + index = self.last_surface_index | |
148 | 151 | proj = prj.Project() |
149 | 152 | surface = proj.surface_dict[index] |
150 | 153 | |
151 | 154 | new_polydata = pu.SelectLargestPart(surface.polydata) |
152 | 155 | self.CreateSurfaceFromPolydata(new_polydata) |
156 | + #TODO: Hide previous | |
153 | 157 | |
154 | 158 | def CreateSurfaceFromPolydata(self, polydata, overwrite=False): |
155 | 159 | mapper = vtk.vtkPolyDataMapper() |
... | ... | @@ -170,6 +174,7 @@ class SurfaceManager(): |
170 | 174 | # Set actor colour and transparency |
171 | 175 | actor.GetProperty().SetColor(surface.colour) |
172 | 176 | actor.GetProperty().SetOpacity(1-surface.transparency) |
177 | + self.actors_dict[surface.index] = actor | |
173 | 178 | |
174 | 179 | # Append surface into Project.surface_dict |
175 | 180 | proj = prj.Project() |
... | ... | @@ -185,8 +190,6 @@ class SurfaceManager(): |
185 | 190 | |
186 | 191 | # The following lines have to be here, otherwise all volumes disappear |
187 | 192 | measured_polydata = vtk.vtkMassProperties() |
188 | - measured_polydata.AddObserver("ProgressEvent", lambda obj,evt: | |
189 | - UpdateProgress(obj, _("Generating 3D surface..."))) | |
190 | 193 | measured_polydata.SetInput(polydata) |
191 | 194 | volume = measured_polydata.GetVolume() |
192 | 195 | surface.volume = volume |
... | ... | @@ -194,6 +197,11 @@ class SurfaceManager(): |
194 | 197 | |
195 | 198 | ps.Publisher().sendMessage('Load surface actor into viewer', actor) |
196 | 199 | |
200 | + ps.Publisher().sendMessage('Update surface info in GUI', | |
201 | + (surface.index, surface.name, | |
202 | + surface.colour, surface.volume, | |
203 | + surface.transparency)) | |
204 | + | |
197 | 205 | |
198 | 206 | def OnCloseProject(self, pubsub_evt): |
199 | 207 | self.CloseProject() | ... | ... |
invesalius/gui/task_surface.py
... | ... | @@ -327,6 +327,7 @@ class SurfaceTools(wx.Panel): |
327 | 327 | self.SelectSeed() |
328 | 328 | |
329 | 329 | def OnButton(self, evt): |
330 | + id = evt.GetId() | |
330 | 331 | if id == BTN_LARGEST: |
331 | 332 | self.SelectLargest() |
332 | 333 | elif id == BTN_SPLIT: |
... | ... | @@ -336,11 +337,12 @@ class SurfaceTools(wx.Panel): |
336 | 337 | |
337 | 338 | def SelectLargest(self): |
338 | 339 | index = self.combo_surface_name.GetSelection() |
339 | - ps.Publisher().sendMessage('Split surface', index) | |
340 | + ps.Publisher().sendMessage('Create surface from largest region', index) | |
340 | 341 | |
341 | 342 | def SplitSurface(self): |
342 | 343 | index = self.combo_surface_name.GetSelection() |
343 | - ps.Publisher().sendMessage('Create surface from largest region', index) | |
344 | + ps.Publisher().sendMessage('Split surface', index) | |
345 | + | |
344 | 346 | # surface_manager |
345 | 347 | |
346 | 348 | def SelectSeed(self): | ... | ... |