Commit 208b8ff64786cac29acc6748db48ad94b2b70e6f
1 parent
298863b6
Exists in
master
and in
68 other branches
ENH: Coloring the slice number based on slice orientation
Showing
2 changed files
with
15 additions
and
3 deletions
Show diff stats
invesalius/data/slice_data.py
| @@ -18,20 +18,25 @@ | @@ -18,20 +18,25 @@ | ||
| 18 | #-------------------------------------------------------------------------- | 18 | #-------------------------------------------------------------------------- |
| 19 | import vtk | 19 | import vtk |
| 20 | 20 | ||
| 21 | +import constants as const | ||
| 22 | + | ||
| 21 | class SliceData(object): | 23 | class SliceData(object): |
| 22 | def __init__(self): | 24 | def __init__(self): |
| 23 | - self.renderer = None | ||
| 24 | self.actor = None | 25 | self.actor = None |
| 25 | - self.number = 0 | ||
| 26 | self.cursor = None | 26 | self.cursor = None |
| 27 | + self.number = 0 | ||
| 28 | + self.orientation = 'AXIAL' | ||
| 29 | + self.renderer = None | ||
| 27 | self.__create_text() | 30 | self.__create_text() |
| 28 | 31 | ||
| 29 | def __create_text(self): | 32 | def __create_text(self): |
| 33 | + colour = const.ORIENTATION_COLOUR[self.orientation] | ||
| 30 | text_property = vtk.vtkTextProperty() | 34 | text_property = vtk.vtkTextProperty() |
| 35 | + text_property.SetColor(colour) | ||
| 31 | text_property.SetFontSize(16) | 36 | text_property.SetFontSize(16) |
| 32 | text_property.SetFontFamilyToTimes() | 37 | text_property.SetFontFamilyToTimes() |
| 33 | text_property.BoldOn() | 38 | text_property.BoldOn() |
| 34 | - #text_property.SetColor(colour) | 39 | + self.text_property = text_property |
| 35 | 40 | ||
| 36 | text_actor = vtk.vtkTextActor() | 41 | text_actor = vtk.vtkTextActor() |
| 37 | text_actor.SetInput("%d" % self.number) | 42 | text_actor.SetInput("%d" % self.number) |
| @@ -49,6 +54,12 @@ class SliceData(object): | @@ -49,6 +54,12 @@ class SliceData(object): | ||
| 49 | self.renderer.AddActor(cursor.actor) | 54 | self.renderer.AddActor(cursor.actor) |
| 50 | self.cursor = cursor | 55 | self.cursor = cursor |
| 51 | 56 | ||
| 57 | + def SetOrientation(self, orientation): | ||
| 58 | + self.orientation = orientation | ||
| 59 | + colour = const.ORIENTATION_COLOUR[self.orientation] | ||
| 60 | + self.text_property.SetColor(colour) | ||
| 61 | + self.text_actor.GetTextProperty().ShallowCopy(self.text_property) | ||
| 62 | + | ||
| 52 | def Hide(self): | 63 | def Hide(self): |
| 53 | self.renderer.RemoveActor(self.actor) | 64 | self.renderer.RemoveActor(self.actor) |
| 54 | self.renderer.RemoveActor(self.text_actor) | 65 | self.renderer.RemoveActor(self.text_actor) |
invesalius/data/viewer_slice.py
| @@ -1021,6 +1021,7 @@ class Viewer(wx.Panel): | @@ -1021,6 +1021,7 @@ class Viewer(wx.Panel): | ||
| 1021 | actor = vtk.vtkImageActor() | 1021 | actor = vtk.vtkImageActor() |
| 1022 | actor.SetInput(imagedata) | 1022 | actor.SetInput(imagedata) |
| 1023 | slice_data = SliceData() | 1023 | slice_data = SliceData() |
| 1024 | + slice_data.SetOrientation(self.orientation) | ||
| 1024 | slice_data.renderer = renderer | 1025 | slice_data.renderer = renderer |
| 1025 | slice_data.actor = actor | 1026 | slice_data.actor = actor |
| 1026 | renderer.AddActor(actor) | 1027 | renderer.AddActor(actor) |