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