Commit 93ef8d8f207716eacc302f98562313ca62dab3e1
1 parent
5027afe1
Exists in
master
Navigation without a surface and closing in navigation mode was not working
Showing
1 changed file
with
7 additions
and
3 deletions
Show diff stats
invesalius/data/viewer_volume.py
@@ -1140,9 +1140,13 @@ class Viewer(wx.Panel): | @@ -1140,9 +1140,13 @@ class Viewer(wx.Panel): | ||
1140 | return actor_arrow | 1140 | return actor_arrow |
1141 | 1141 | ||
1142 | def CenterOfMass(self): | 1142 | def CenterOfMass(self): |
1143 | - proj = prj.Project() | ||
1144 | - surface = proj.surface_dict[0].polydata | ||
1145 | barycenter = [0.0, 0.0, 0.0] | 1143 | barycenter = [0.0, 0.0, 0.0] |
1144 | + proj = prj.Project() | ||
1145 | + try: | ||
1146 | + surface = proj.surface_dict[0].polydata | ||
1147 | + except KeyError: | ||
1148 | + print("There is not any surface created") | ||
1149 | + return barycenter | ||
1146 | n = surface.GetNumberOfPoints() | 1150 | n = surface.GetNumberOfPoints() |
1147 | for i in range(n): | 1151 | for i in range(n): |
1148 | point = surface.GetPoint(i) | 1152 | point = surface.GetPoint(i) |
@@ -1356,9 +1360,9 @@ class Viewer(wx.Panel): | @@ -1356,9 +1360,9 @@ class Viewer(wx.Panel): | ||
1356 | def OnNavigationStatus(self, nav_status, vis_status): | 1360 | def OnNavigationStatus(self, nav_status, vis_status): |
1357 | self.nav_status = nav_status | 1361 | self.nav_status = nav_status |
1358 | self.tracts_status = vis_status[1] | 1362 | self.tracts_status = vis_status[1] |
1359 | - self.pTarget = self.CenterOfMass() | ||
1360 | 1363 | ||
1361 | if self.nav_status: | 1364 | if self.nav_status: |
1365 | + self.pTarget = self.CenterOfMass() | ||
1362 | if self.obj_actor: | 1366 | if self.obj_actor: |
1363 | self.obj_actor.SetVisibility(self.obj_state) | 1367 | self.obj_actor.SetVisibility(self.obj_state) |
1364 | self.x_actor.SetVisibility(self.obj_state) | 1368 | self.x_actor.SetVisibility(self.obj_state) |