Commit 208b8ff64786cac29acc6748db48ad94b2b70e6f
1 parent
298863b6
Exists in
master
and in
6 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 | 18 | #-------------------------------------------------------------------------- |
19 | 19 | import vtk |
20 | 20 | |
21 | +import constants as const | |
22 | + | |
21 | 23 | class SliceData(object): |
22 | 24 | def __init__(self): |
23 | - self.renderer = None | |
24 | 25 | self.actor = None |
25 | - self.number = 0 | |
26 | 26 | self.cursor = None |
27 | + self.number = 0 | |
28 | + self.orientation = 'AXIAL' | |
29 | + self.renderer = None | |
27 | 30 | self.__create_text() |
28 | 31 | |
29 | 32 | def __create_text(self): |
33 | + colour = const.ORIENTATION_COLOUR[self.orientation] | |
30 | 34 | text_property = vtk.vtkTextProperty() |
35 | + text_property.SetColor(colour) | |
31 | 36 | text_property.SetFontSize(16) |
32 | 37 | text_property.SetFontFamilyToTimes() |
33 | 38 | text_property.BoldOn() |
34 | - #text_property.SetColor(colour) | |
39 | + self.text_property = text_property | |
35 | 40 | |
36 | 41 | text_actor = vtk.vtkTextActor() |
37 | 42 | text_actor.SetInput("%d" % self.number) |
... | ... | @@ -49,6 +54,12 @@ class SliceData(object): |
49 | 54 | self.renderer.AddActor(cursor.actor) |
50 | 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 | 63 | def Hide(self): |
53 | 64 | self.renderer.RemoveActor(self.actor) |
54 | 65 | self.renderer.RemoveActor(self.text_actor) | ... | ... |
invesalius/data/viewer_slice.py
... | ... | @@ -1021,6 +1021,7 @@ class Viewer(wx.Panel): |
1021 | 1021 | actor = vtk.vtkImageActor() |
1022 | 1022 | actor.SetInput(imagedata) |
1023 | 1023 | slice_data = SliceData() |
1024 | + slice_data.SetOrientation(self.orientation) | |
1024 | 1025 | slice_data.renderer = renderer |
1025 | 1026 | slice_data.actor = actor |
1026 | 1027 | renderer.AddActor(actor) | ... | ... |