Commit 7ae6eefe50044cfa6c9d996cdd717afcd8d75bb0
1 parent
8e626c40
Exists in
master
REFACTOR variable name for marker list from staticballs to static_markers and AD…
…D conditions for markers and balls during navigation
Showing
2 changed files
with
23 additions
and
23 deletions
Show diff stats
invesalius/data/viewer_volume.py
| @@ -70,7 +70,7 @@ class Viewer(wx.Panel): | @@ -70,7 +70,7 @@ class Viewer(wx.Panel): | ||
| 70 | 70 | ||
| 71 | self.initial_focus = None | 71 | self.initial_focus = None |
| 72 | 72 | ||
| 73 | - self.staticballs = [] | 73 | + self.static_markers = [] |
| 74 | self.static_arrows =[] | 74 | self.static_arrows =[] |
| 75 | self.style = None | 75 | self.style = None |
| 76 | 76 | ||
| @@ -580,7 +580,7 @@ class Viewer(wx.Panel): | @@ -580,7 +580,7 @@ class Viewer(wx.Panel): | ||
| 580 | """ | 580 | """ |
| 581 | Set all markers, overwriting the previous markers. | 581 | Set all markers, overwriting the previous markers. |
| 582 | """ | 582 | """ |
| 583 | - self.RemoveAllMarkers(len(self.staticballs)) | 583 | + self.RemoveAllMarkers(len(self.static_markers)) |
| 584 | 584 | ||
| 585 | target_selected = False | 585 | target_selected = False |
| 586 | for marker in markers: | 586 | for marker in markers: |
| @@ -617,8 +617,8 @@ class Viewer(wx.Panel): | @@ -617,8 +617,8 @@ class Viewer(wx.Panel): | ||
| 617 | coord_flip[1] = -coord_flip[1] | 617 | coord_flip[1] = -coord_flip[1] |
| 618 | 618 | ||
| 619 | arrow_actor = self.Add_ObjectArrow(coord_flip[:3], coord_flip[3:6], color, size) | 619 | arrow_actor = self.Add_ObjectArrow(coord_flip[:3], coord_flip[3:6], color, size) |
| 620 | - self.staticballs.append(arrow_actor) | ||
| 621 | - self.ren.AddActor(self.staticballs[self.arrow_marker_id]) | 620 | + self.static_markers.append(arrow_actor) |
| 621 | + self.ren.AddActor(self.static_markers[self.arrow_marker_id]) | ||
| 622 | self.arrow_marker_id +=1 | 622 | self.arrow_marker_id +=1 |
| 623 | #self.UpdateRender() | 623 | #self.UpdateRender() |
| 624 | self.Refresh() | 624 | self.Refresh() |
| @@ -643,12 +643,12 @@ class Viewer(wx.Panel): | @@ -643,12 +643,12 @@ class Viewer(wx.Panel): | ||
| 643 | prop.SetColor(colour) | 643 | prop.SetColor(colour) |
| 644 | 644 | ||
| 645 | # adding a new actor for the present ball | 645 | # adding a new actor for the present ball |
| 646 | - self.staticballs.append(vtk.vtkActor()) | 646 | + self.static_markers.append(vtk.vtkActor()) |
| 647 | 647 | ||
| 648 | - self.staticballs[self.ball_id].SetMapper(mapper) | ||
| 649 | - self.staticballs[self.ball_id].SetProperty(prop) | 648 | + self.static_markers[self.ball_id].SetMapper(mapper) |
| 649 | + self.static_markers[self.ball_id].SetProperty(prop) | ||
| 650 | 650 | ||
| 651 | - self.ren.AddActor(self.staticballs[self.ball_id]) | 651 | + self.ren.AddActor(self.static_markers[self.ball_id]) |
| 652 | self.ball_id += 1 | 652 | self.ball_id += 1 |
| 653 | 653 | ||
| 654 | #self.UpdateRender() | 654 | #self.UpdateRender() |
| @@ -684,33 +684,33 @@ class Viewer(wx.Panel): | @@ -684,33 +684,33 @@ class Viewer(wx.Panel): | ||
| 684 | def HideAllMarkers(self, indexes): | 684 | def HideAllMarkers(self, indexes): |
| 685 | ballid = indexes | 685 | ballid = indexes |
| 686 | for i in range(0, ballid): | 686 | for i in range(0, ballid): |
| 687 | - self.staticballs[i].SetVisibility(0) | 687 | + self.static_markers[i].SetVisibility(0) |
| 688 | self.UpdateRender() | 688 | self.UpdateRender() |
| 689 | 689 | ||
| 690 | def ShowAllMarkers(self, indexes): | 690 | def ShowAllMarkers(self, indexes): |
| 691 | ballid = indexes | 691 | ballid = indexes |
| 692 | for i in range(0, ballid): | 692 | for i in range(0, ballid): |
| 693 | - self.staticballs[i].SetVisibility(1) | 693 | + self.static_markers[i].SetVisibility(1) |
| 694 | self.UpdateRender() | 694 | self.UpdateRender() |
| 695 | 695 | ||
| 696 | def RemoveAllMarkers(self, indexes): | 696 | def RemoveAllMarkers(self, indexes): |
| 697 | ballid = indexes | 697 | ballid = indexes |
| 698 | for i in range(0, ballid): | 698 | for i in range(0, ballid): |
| 699 | - self.ren.RemoveActor(self.staticballs[i]) | ||
| 700 | - self.staticballs = [] | 699 | + self.ren.RemoveActor(self.static_markers[i]) |
| 700 | + self.static_markers = [] | ||
| 701 | self.UpdateRender() | 701 | self.UpdateRender() |
| 702 | 702 | ||
| 703 | def RemoveMultipleMarkers(self, index): | 703 | def RemoveMultipleMarkers(self, index): |
| 704 | for i in reversed(index): | 704 | for i in reversed(index): |
| 705 | - self.ren.RemoveActor(self.staticballs[i]) | ||
| 706 | - del self.staticballs[i] | 705 | + self.ren.RemoveActor(self.static_markers[i]) |
| 706 | + del self.static_markers[i] | ||
| 707 | self.ball_id = self.ball_id - 1 | 707 | self.ball_id = self.ball_id - 1 |
| 708 | self.UpdateRender() | 708 | self.UpdateRender() |
| 709 | 709 | ||
| 710 | def BlinkMarker(self, index): | 710 | def BlinkMarker(self, index): |
| 711 | if self.timer: | 711 | if self.timer: |
| 712 | self.timer.Stop() | 712 | self.timer.Stop() |
| 713 | - self.staticballs[self.index].SetVisibility(1) | 713 | + self.static_markers[self.index].SetVisibility(1) |
| 714 | self.index = index | 714 | self.index = index |
| 715 | self.timer = wx.Timer(self) | 715 | self.timer = wx.Timer(self) |
| 716 | self.Bind(wx.EVT_TIMER, self.OnBlinkMarker, self.timer) | 716 | self.Bind(wx.EVT_TIMER, self.OnBlinkMarker, self.timer) |
| @@ -718,7 +718,7 @@ class Viewer(wx.Panel): | @@ -718,7 +718,7 @@ class Viewer(wx.Panel): | ||
| 718 | self.timer_count = 0 | 718 | self.timer_count = 0 |
| 719 | 719 | ||
| 720 | def OnBlinkMarker(self, evt): | 720 | def OnBlinkMarker(self, evt): |
| 721 | - self.staticballs[self.index].SetVisibility(int(self.timer_count % 2)) | 721 | + self.static_markers[self.index].SetVisibility(int(self.timer_count % 2)) |
| 722 | self.Refresh() | 722 | self.Refresh() |
| 723 | self.timer_count += 1 | 723 | self.timer_count += 1 |
| 724 | 724 | ||
| @@ -726,20 +726,20 @@ class Viewer(wx.Panel): | @@ -726,20 +726,20 @@ class Viewer(wx.Panel): | ||
| 726 | if self.timer: | 726 | if self.timer: |
| 727 | self.timer.Stop() | 727 | self.timer.Stop() |
| 728 | if index is None: | 728 | if index is None: |
| 729 | - self.staticballs[self.index].SetVisibility(1) | 729 | + self.static_markers[self.index].SetVisibility(1) |
| 730 | self.Refresh() | 730 | self.Refresh() |
| 731 | self.index = False | 731 | self.index = False |
| 732 | 732 | ||
| 733 | def SetNewColor(self, index, color): | 733 | def SetNewColor(self, index, color): |
| 734 | - self.staticballs[index].GetProperty().SetColor([round(s/255.0, 3) for s in color]) | 734 | + self.static_markers[index].GetProperty().SetColor([round(s / 255.0, 3) for s in color]) |
| 735 | self.Refresh() | 735 | self.Refresh() |
| 736 | 736 | ||
| 737 | def OnTargetMarkerTransparency(self, status, index): | 737 | def OnTargetMarkerTransparency(self, status, index): |
| 738 | if status: | 738 | if status: |
| 739 | - self.staticballs[index].GetProperty().SetOpacity(1) | 739 | + self.static_markers[index].GetProperty().SetOpacity(1) |
| 740 | # self.staticballs[index].GetProperty().SetOpacity(0.4) | 740 | # self.staticballs[index].GetProperty().SetOpacity(0.4) |
| 741 | else: | 741 | else: |
| 742 | - self.staticballs[index].GetProperty().SetOpacity(1) | 742 | + self.static_markers[index].GetProperty().SetOpacity(1) |
| 743 | 743 | ||
| 744 | def OnUpdateAngleThreshold(self, angle): | 744 | def OnUpdateAngleThreshold(self, angle): |
| 745 | self.anglethreshold = angle | 745 | self.anglethreshold = angle |
invesalius/gui/task_navigator.py
| @@ -1617,8 +1617,8 @@ class MarkersPanel(wx.Panel): | @@ -1617,8 +1617,8 @@ class MarkersPanel(wx.Panel): | ||
| 1617 | self.__set_marker_as_target(len(self.markers) - 1) | 1617 | self.__set_marker_as_target(len(self.markers) - 1) |
| 1618 | 1618 | ||
| 1619 | except Exception as e: | 1619 | except Exception as e: |
| 1620 | - print('hereee',e) | ||
| 1621 | - wx.MessageBox(_("Invalid markers file."), _("InVesalius 3")) | 1620 | + |
| 1621 | + wx.MessageBox(_("Invalid markers file."), _("InVesalius 3")) | ||
| 1622 | 1622 | ||
| 1623 | def OnMarkersVisibility(self, evt, ctrl): | 1623 | def OnMarkersVisibility(self, evt, ctrl): |
| 1624 | if ctrl.GetValue(): | 1624 | if ctrl.GetValue(): |
| @@ -1689,7 +1689,7 @@ class MarkersPanel(wx.Panel): | @@ -1689,7 +1689,7 @@ class MarkersPanel(wx.Panel): | ||
| 1689 | colour=new_marker.colour, | 1689 | colour=new_marker.colour, |
| 1690 | coord=new_marker.coord[:3]) | 1690 | coord=new_marker.coord[:3]) |
| 1691 | 1691 | ||
| 1692 | - elif new_marker.coord[3:] is not None and self.nav_status: | 1692 | + elif new_marker.coord[3:] is not None and self.nav_status or session_id is not None: |
| 1693 | Publisher.sendMessage('Add arrow marker', arrow_id=len(self.markers), | 1693 | Publisher.sendMessage('Add arrow marker', arrow_id=len(self.markers), |
| 1694 | size=self.arrow_marker_size, | 1694 | size=self.arrow_marker_size, |
| 1695 | color=new_marker.colour, | 1695 | color=new_marker.colour, |