Commit 3ca2cf40f8454f24332d7db7a94ec4c18c29a0ee
1 parent
201ada86
Exists in
master
and in
6 other branches
ENH: Text actors in slice
Showing
6 changed files
with
59 additions
and
39 deletions
Show diff stats
invesalius/constants.py
... | ... | @@ -29,17 +29,29 @@ from project import Project |
29 | 29 | TEXT_SIZE = 14 |
30 | 30 | TEXT_SIZE_LARGE = 16 |
31 | 31 | TEXT_COLOUR = (1,1,1) |
32 | + | |
32 | 33 | (X,Y) = (0.03, 0.97) |
33 | 34 | TEXT_POS_LEFT_UP = (X, Y) |
34 | -TEXT_POS_LEFT_DOWN = (X, 1-Y) | |
35 | -TEXT_POS_LEFT_DOWN_SLC = (X, 1-0.93) | |
36 | -TEXT_POS_RIGHT_UP = (1-X, Y) | |
37 | -TEXT_POS_RIGHT_DOWN = (1-X, 1-Y) | |
38 | 35 | TEXT_POSITION = TEXT_POS_LEFT_UP |
39 | -TEXT_POS_HCENTRE_UP = (0.5, 0.97) | |
40 | -TEXT_POS_HCENTRE_DOWN = (0.5, 0.07) | |
41 | -TEXT_POS_VCENTRE_RIGHT = (0.95, 0.5) | |
42 | -TEXT_POS_VCENPRE_LEFT = (0.03, 0.5) | |
36 | +#------------------------------------------------------------------ | |
37 | +TEXT_POS_LEFT_DOWN = (X, 1-Y) # SetVerticalJustificationToBottom | |
38 | +#------------------------------------------------------------------ | |
39 | +TEXT_POS_RIGHT_UP = (1-X, Y) # SetJustificationToRight | |
40 | +#------------------------------------------------------------------ | |
41 | +TEXT_POS_RIGHT_DOWN = (1-X, 1-Y) # SetVerticalJustificationToBottom & | |
42 | + # SetJustificationToRight | |
43 | +#------------------------------------------------------------------ | |
44 | +TEXT_POS_HCENTRE_DOWN = (0.5, 1-Y) # SetJustificationToCentered | |
45 | + # SetVerticalJustificationToBottom | |
46 | +#------------------------------------------------------------------ | |
47 | +TEXT_POS_HCENTRE_UP = (0.5, Y) # SetJustificationToCentered | |
48 | +#------------------------------------------------------------------ | |
49 | +TEXT_POS_VCENTRE_RIGHT = (1-X, 0.5) # SetVerticalJustificationToCentered | |
50 | + # SetJustificationToRight | |
51 | +#------------------------------------------------------------------ | |
52 | +TEXT_POS_VCENTRE_LEFT = (X, 0.5) # SetVerticalJustificationToCentered | |
53 | +#------------------------------------------------------------------ | |
54 | + | |
43 | 55 | |
44 | 56 | # Slice orientation |
45 | 57 | AXIAL = 0 | ... | ... |
invesalius/data/slice_data.py
... | ... | @@ -34,10 +34,10 @@ class SliceData(object): |
34 | 34 | colour = const.ORIENTATION_COLOUR[self.orientation] |
35 | 35 | |
36 | 36 | text = vu.Text() |
37 | - #text.BoldOn() | |
38 | 37 | text.SetColour(colour) |
39 | - text.SetPosition(const.TEXT_POS_LEFT_DOWN_SLC) | |
40 | 38 | text.SetSize(const.TEXT_SIZE_LARGE) |
39 | + text.SetPosition(const.TEXT_POS_LEFT_DOWN) | |
40 | + text.SetVerticalJustificationToBottom() | |
41 | 41 | text.SetValue(self.number) |
42 | 42 | self.text = text |
43 | 43 | ... | ... |
invesalius/data/viewer_slice.py
... | ... | @@ -387,14 +387,15 @@ class Viewer(wx.Panel): |
387 | 387 | |
388 | 388 | def EnableText(self): |
389 | 389 | if not (self.wl_text): |
390 | - text = self.wl_text = vtku.Text() | |
391 | - self.ren.AddActor(text.actor) | |
392 | - proj = project.Project() | |
393 | - self.SetWLText(proj.level, proj.window) | |
394 | - | |
390 | + proj = project.Project() | |
395 | 391 | colour = const.ORIENTATION_COLOUR[self.orientation] |
396 | 392 | |
397 | - #### Orientation text | |
393 | + # Window & Level text | |
394 | + self.wl_text = vtku.Text() | |
395 | + self.SetWLText(proj.level, proj.window) | |
396 | + | |
397 | + | |
398 | + # Orientation text | |
398 | 399 | if self.orientation == 'AXIAL': |
399 | 400 | values = ['R', 'L', 'A', 'P'] |
400 | 401 | elif self.orientation == 'SAGITAL': |
... | ... | @@ -403,32 +404,40 @@ class Viewer(wx.Panel): |
403 | 404 | values = ['P', 'A', 'T', 'B'] |
404 | 405 | |
405 | 406 | left_text = vtku.Text() |
406 | - left_text.SetColour(colour) | |
407 | 407 | left_text.ShadowOff() |
408 | - left_text.SetPosition(const.TEXT_POS_VCENPRE_LEFT) | |
408 | + left_text.SetColour(colour) | |
409 | + left_text.SetPosition(const.TEXT_POS_VCENTRE_LEFT) | |
410 | + left_text.SetVerticalJustificationToCentered() | |
409 | 411 | left_text.SetValue(values[0]) |
410 | 412 | |
411 | 413 | right_text = vtku.Text() |
412 | - right_text.SetColour(colour) | |
413 | 414 | right_text.ShadowOff() |
415 | + right_text.SetColour(colour) | |
414 | 416 | right_text.SetPosition(const.TEXT_POS_VCENTRE_RIGHT) |
417 | + right_text.SetVerticalJustificationToCentered() | |
418 | + right_text.SetJustificationToRight() | |
415 | 419 | right_text.SetValue(values[1]) |
416 | 420 | |
417 | 421 | up_text = vtku.Text() |
418 | - up_text.SetColour(colour) | |
419 | 422 | up_text.ShadowOff() |
423 | + up_text.SetColour(colour) | |
420 | 424 | up_text.SetPosition(const.TEXT_POS_HCENTRE_UP) |
425 | + up_text.SetJustificationToCentered() | |
421 | 426 | up_text.SetValue(values[2]) |
422 | 427 | |
423 | 428 | down_text = vtku.Text() |
424 | - down_text.SetColour(colour) | |
425 | 429 | down_text.ShadowOff() |
430 | + down_text.SetColour(colour) | |
426 | 431 | down_text.SetPosition(const.TEXT_POS_HCENTRE_DOWN) |
432 | + down_text.SetJustificationToCentered() | |
433 | + down_text.SetVerticalJustificationToBottom() | |
427 | 434 | down_text.SetValue(values[3]) |
428 | 435 | |
429 | 436 | self.orientation_texts = [left_text, right_text, up_text, |
430 | - down_text] | |
437 | + down_text] | |
438 | + | |
431 | 439 | |
440 | + self.ren.AddActor(self.wl_text.actor) | |
432 | 441 | self.ren.AddActor(left_text.actor) |
433 | 442 | self.ren.AddActor(right_text.actor) |
434 | 443 | self.ren.AddActor(up_text.actor) |
... | ... | @@ -835,12 +844,9 @@ class Viewer(wx.Panel): |
835 | 844 | position = (slice_xi, slice_yi, slice_xf, slice_yf) |
836 | 845 | slice_data = self.slice_data_list[n] |
837 | 846 | slice_data.renderer.SetViewport(position) |
838 | - x = slice_xi + (0.03*proportion_x) | |
839 | - ratio = 0 | |
840 | - if self.layout[1] > 1: | |
841 | - ratio = 0.04 | |
842 | - y = slice_yi +(0.09*proportion_y)+ratio | |
843 | - slice_data.text.SetPosition((x,y)) | |
847 | + # Text actor position | |
848 | + x, y = const.TEXT_POS_LEFT_DOWN | |
849 | + slice_data.text.SetPosition((x+slice_xi,y+slice_yi)) | |
844 | 850 | slice_data.SetCursor(self.__create_cursor()) |
845 | 851 | self.__update_camera(slice_data) |
846 | 852 | n += 1 | ... | ... |
invesalius/data/vtk_utils.py
... | ... | @@ -103,13 +103,13 @@ class Text(object): |
103 | 103 | mapper.SetTextProperty(property) |
104 | 104 | self.mapper = mapper |
105 | 105 | |
106 | - x, y = const.TEXT_POSITION | |
107 | 106 | actor = vtk.vtkActor2D() |
108 | 107 | actor.SetMapper(mapper) |
109 | 108 | actor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay() |
110 | - actor.GetPositionCoordinate().SetValue(x,y) | |
111 | 109 | self.actor = actor |
112 | 110 | |
111 | + self.SetPosition(const.TEXT_POS_LEFT_UP) | |
112 | + | |
113 | 113 | def SetColour(self, colour): |
114 | 114 | self.property.SetColor(colour) |
115 | 115 | |
... | ... | @@ -137,9 +137,15 @@ class Text(object): |
137 | 137 | def SetJustificationToRight(self): |
138 | 138 | self.property.SetJustificationToRight() |
139 | 139 | |
140 | + def SetJustificationToCentered(self): | |
141 | + self.property.SetJustificationToCentered() | |
142 | + | |
143 | + | |
140 | 144 | def SetVerticalJustificationToBottom(self): |
141 | 145 | self.property.SetVerticalJustificationToBottom() |
142 | 146 | |
147 | + def SetVerticalJustificationToCentered(self): | |
148 | + self.property.SetVerticalJustificationToCentered() | |
143 | 149 | |
144 | 150 | def Show(self, value=1): |
145 | 151 | if value: | ... | ... |
invesalius/gui/dicom_preview_panel.py
... | ... | @@ -60,33 +60,29 @@ class SingleImagePreview(wx.Panel): |
60 | 60 | actor = vtk.vtkImageActor() |
61 | 61 | self.actor = actor |
62 | 62 | |
63 | - LEFT_UP = (X, Y) = const.TEXT_POS_LEFT_UP | |
64 | 63 | text_image_size = vtku.Text() |
65 | - text_image_size.SetPosition(LEFT_UP) | |
64 | + text_image_size.SetPosition(const.TEXT_POS_LEFT_UP) | |
66 | 65 | text_image_size.SetValue("image size") |
67 | 66 | self.text_image_size = text_image_size |
68 | 67 | |
69 | - LEFT_DOWN = (X, 1-Y) | |
70 | 68 | text_image_location = vtku.Text() |
71 | 69 | text_image_location.SetVerticalJustificationToBottom() |
72 | - text_image_location.SetPosition(LEFT_DOWN) | |
70 | + text_image_location.SetPosition(const.TEXT_POS_LEFT_DOWN) | |
73 | 71 | text_image_location.SetValue("localization") |
74 | 72 | self.text_image_location = text_image_location |
75 | 73 | |
76 | 74 | value = "id\nprotocol" |
77 | - RIGHT_UP = (1-X, Y) | |
78 | 75 | text_patient = vtku.Text() |
79 | 76 | text_patient.SetJustificationToRight() |
80 | - text_patient.SetPosition(RIGHT_UP) | |
77 | + text_patient.SetPosition(const.TEXT_POS_RIGHT_UP) | |
81 | 78 | text_patient.SetValue(value) |
82 | 79 | self.text_patient = text_patient |
83 | 80 | |
84 | 81 | value = "date time\n Made in InVesalius" |
85 | - RIGHT_DOWN = (1-X, 1-Y) | |
86 | 82 | text_acquisition = vtku.Text() |
87 | 83 | text_acquisition.SetJustificationToRight() |
88 | 84 | text_acquisition.SetVerticalJustificationToBottom() |
89 | - text_acquisition.SetPosition(RIGHT_DOWN) | |
85 | + text_acquisition.SetPosition(const.TEXT_POS_RIGHT_DOWN) | |
90 | 86 | text_acquisition.SetValue(value) |
91 | 87 | self.text_acquisition = text_acquisition |
92 | 88 | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -451,7 +451,7 @@ class ProjectToolBar(wx.ToolBar): |
451 | 451 | def OnToolImport(self, event): |
452 | 452 | dirpath = dlg.ShowImportDirDialog() |
453 | 453 | if dirpath: |
454 | - ps.Publisher().sendMessage("Load data to import panel", path) | |
454 | + ps.Publisher().sendMessage("Load data to import panel", dirpath) | |
455 | 455 | event.Skip() |
456 | 456 | |
457 | 457 | def OnToolOpen(self, event): | ... | ... |