Commit 486d4343e22b7277ec279482e448157e94ac13ba

Authored by Renan
1 parent 6c487aa0
Exists in master

FIX: Load markers deal with None angles

Showing 1 changed file with 6 additions and 7 deletions   Show diff stats
invesalius/gui/task_navigator.py
... ... @@ -1222,8 +1222,10 @@ class MarkersPanel(wx.Panel):
1222 1222 properly formatted, might throw an exception and leave the object
1223 1223 in an inconsistent state."""
1224 1224 for field, str_val in zip(dataclasses.fields(self.__class__), inp_str.split('\t')):
1225   - if field.type is float:
  1225 + if field.type is float and str_val != 'None':
1226 1226 setattr(self, field.name, float(str_val))
  1227 + if field.type is float and str_val == 'None':
  1228 + setattr(self, field.name, None)
1227 1229 if field.type is int:
1228 1230 setattr(self, field.name, int(str_val))
1229 1231 if field.type is str:
... ... @@ -1261,7 +1263,6 @@ class MarkersPanel(wx.Panel):
1261 1263 self.session = ses.Session()
1262 1264  
1263 1265 self.current_coord = 0, 0, 0, None, None, None
1264   - self.current_angle = None, None, None
1265 1266 self.current_seed = 0, 0, 0
1266 1267 self.current_robot_target_matrix = [None] * 9
1267 1268 self.markers = []
... ... @@ -1439,13 +1440,11 @@ class MarkersPanel(wx.Panel):
1439 1440 return list(itertools.chain(*(const.BTNS_IMG_MARKERS[i].values() for i in const.BTNS_IMG_MARKERS)))
1440 1441  
1441 1442 def UpdateCurrentCoord(self, position):
1442   - self.current_coord = position
1443   - #self.current_angle = pubsub_evt.data[1][3:]
  1443 + self.current_coord = list(position)
1444 1444  
1445 1445 def UpdateNavigationStatus(self, nav_status, vis_status):
1446 1446 if not nav_status:
1447   - sleep(0.5)
1448   - #self.current_coord[3:] = 0, 0, 0
  1447 + self.current_coord[3:] = None, None, None
1449 1448 self.nav_status = False
1450 1449 else:
1451 1450 self.nav_status = True
... ... @@ -1696,7 +1695,7 @@ class MarkersPanel(wx.Panel):
1696 1695 colour=new_marker.colour,
1697 1696 coord=new_marker.coord[:3])
1698 1697  
1699   - elif new_marker.coord[3:] is not None and self.nav_status or session_id is not None:
  1698 + elif all([elem is not None for elem in new_marker.coord[3:]]):
1700 1699 Publisher.sendMessage('Add arrow marker', arrow_id=len(self.markers),
1701 1700 size=self.arrow_marker_size,
1702 1701 color=new_marker.colour,
... ...