Commit cc3c0dc398da96c2a62c6fe994fc6d60433a44bb
Committed by
GitHub
1 parent
bfaca5dc
Exists in
master
and in
23 other branches
Micro ct shift delete (#46)
* FIX: Removed vtk window warming from bitmap import * NEW: Added support to multiple delete files with shift in import bmp files. * NEW: Added support to multiple delete files with shift in import bmp files. * ENH: Text align * ENH: Removed print * ENH: GUI improvements of import bitmap dialog * ENH: Removed unused codes * ENH: Removed unused codes and resized text in bitmap import error dialog
Showing
4 changed files
with
81 additions
and
503 deletions
Show diff stats
invesalius/gui/bitmap_preview_panel.py
| @@ -88,10 +88,8 @@ class BitmapInfo(object): | @@ -88,10 +88,8 @@ class BitmapInfo(object): | ||
| 88 | self.title = data[6] | 88 | self.title = data[6] |
| 89 | self.data = data | 89 | self.data = data |
| 90 | self.pos = data[8] | 90 | self.pos = data[8] |
| 91 | - #self.subtitle = subtitle | ||
| 92 | self._preview = None | 91 | self._preview = None |
| 93 | self.selected = False | 92 | self.selected = False |
| 94 | - #self.filename = "" | ||
| 95 | self.thumbnail_path = data[1] | 93 | self.thumbnail_path = data[1] |
| 96 | 94 | ||
| 97 | @property | 95 | @property |
| @@ -187,50 +185,16 @@ class Preview(wx.Panel): | @@ -187,50 +185,16 @@ class Preview(wx.Panel): | ||
| 187 | 185 | ||
| 188 | def _bind_events(self): | 186 | def _bind_events(self): |
| 189 | self.Bind( wx.EVT_LEFT_DCLICK, self.OnDClick) | 187 | self.Bind( wx.EVT_LEFT_DCLICK, self.OnDClick) |
| 190 | - #self.interactor.Bind( wx.EVT_LEFT_DCLICK, self.OnDClick) | ||
| 191 | - #self.panel.Bind( wx.EVT_LEFT_DCLICK, self.OnDClick) | ||
| 192 | - #self.title.Bind( wx.EVT_LEFT_DCLICK, self.OnDClick) | ||
| 193 | - #self.subtitle.Bind( wx.EVT_LEFT_DCLICK, self.OnDClick) | ||
| 194 | - | ||
| 195 | self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) | 188 | self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) |
| 196 | - #self.interactor.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) | ||
| 197 | - #self.panel.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) | ||
| 198 | - #self.title.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) | ||
| 199 | - #self.subtitle.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) | ||
| 200 | - | ||
| 201 | self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) | 189 | self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) |
| 202 | - #self.interactor.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) | ||
| 203 | - #self.panel.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) | ||
| 204 | - #self.title.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) | ||
| 205 | - #self.subtitle.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) | ||
| 206 | 190 | ||
| 207 | self.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) | 191 | self.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) |
| 208 | self.title.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) | 192 | self.title.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) |
| 209 | self.subtitle.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) | 193 | self.subtitle.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) |
| 210 | self.image_viewer.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) | 194 | self.image_viewer.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) |
| 211 | 195 | ||
| 212 | - #self.Bind(wx.EVT_SIZE, self.OnSize) | ||
| 213 | 196 | ||
| 214 | def SetBitmapToPreview(self, bitmap_info): | 197 | def SetBitmapToPreview(self, bitmap_info): |
| 215 | - """ | ||
| 216 | - Set a dicom to preview. | ||
| 217 | - """ | ||
| 218 | - | ||
| 219 | - """ | ||
| 220 | - self.dicom_info = dicom_info | ||
| 221 | - self.SetTitle(dicom_info.title) | ||
| 222 | - self.SetSubtitle(dicom_info.subtitle) | ||
| 223 | - self.ID = dicom_info.id | ||
| 224 | - dicom_info.size = self.image_viewer.GetSize() | ||
| 225 | - image = dicom_info.preview | ||
| 226 | - self.image_viewer.SetImage(image) | ||
| 227 | - self.data = dicom_info.id | ||
| 228 | - self.select_on = dicom_info.selected | ||
| 229 | - self.Select() | ||
| 230 | - self.Update() | ||
| 231 | - """ | ||
| 232 | - | ||
| 233 | - | ||
| 234 | 198 | ||
| 235 | if self.bitmap_info: | 199 | if self.bitmap_info: |
| 236 | self.bitmap_info.release_thumbnail() | 200 | self.bitmap_info.release_thumbnail() |
| @@ -239,12 +203,9 @@ class Preview(wx.Panel): | @@ -239,12 +203,9 @@ class Preview(wx.Panel): | ||
| 239 | self.SetTitle(self.bitmap_info.title[-10:]) | 203 | self.SetTitle(self.bitmap_info.title[-10:]) |
| 240 | self.SetSubtitle('') | 204 | self.SetSubtitle('') |
| 241 | 205 | ||
| 242 | - ##self.ID = bitmap_info.id | ||
| 243 | - ##bitmap_info.size = self.image_viewer.GetSize() | ||
| 244 | image = self.bitmap_info.preview | 206 | image = self.bitmap_info.preview |
| 245 | 207 | ||
| 246 | self.image_viewer.SetImage(image) | 208 | self.image_viewer.SetImage(image) |
| 247 | - #self.data = bitmap_info.id | ||
| 248 | self.select_on = bitmap_info.selected | 209 | self.select_on = bitmap_info.selected |
| 249 | self.Select() | 210 | self.Select() |
| 250 | self.Update() | 211 | self.Update() |
| @@ -257,7 +218,6 @@ class Preview(wx.Panel): | @@ -257,7 +218,6 @@ class Preview(wx.Panel): | ||
| 257 | 218 | ||
| 258 | def OnEnter(self, evt): | 219 | def OnEnter(self, evt): |
| 259 | if not self.select_on: | 220 | if not self.select_on: |
| 260 | - #c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DHILIGHT) | ||
| 261 | c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) | 221 | c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) |
| 262 | self.SetBackgroundColour(c) | 222 | self.SetBackgroundColour(c) |
| 263 | 223 | ||
| @@ -286,8 +246,6 @@ class Preview(wx.Panel): | @@ -286,8 +246,6 @@ class Preview(wx.Panel): | ||
| 286 | my_evt.SetEventObject(self) | 246 | my_evt.SetEventObject(self) |
| 287 | self.GetEventHandler().ProcessEvent(my_evt) | 247 | self.GetEventHandler().ProcessEvent(my_evt) |
| 288 | 248 | ||
| 289 | - print ">>>",self.bitmap_info.pos, self.bitmap_info.id, self.bitmap_info.data | ||
| 290 | - | ||
| 291 | Publisher.sendMessage('Set bitmap in preview panel', self.bitmap_info.pos) | 249 | Publisher.sendMessage('Set bitmap in preview panel', self.bitmap_info.pos) |
| 292 | 250 | ||
| 293 | evt.Skip() | 251 | evt.Skip() |
| @@ -320,8 +278,6 @@ class BitmapPreviewSeries(wx.Panel): | @@ -320,8 +278,6 @@ class BitmapPreviewSeries(wx.Panel): | ||
| 320 | super(BitmapPreviewSeries, self).__init__(parent) | 278 | super(BitmapPreviewSeries, self).__init__(parent) |
| 321 | # TODO: 3 pixels between the previews is a good idea? | 279 | # TODO: 3 pixels between the previews is a good idea? |
| 322 | # I have to test. | 280 | # I have to test. |
| 323 | - #self.sizer = wx.BoxSizer(wx.HORIZONTAL) | ||
| 324 | - #self.SetSizer(self.sizer) | ||
| 325 | self.displayed_position = 0 | 281 | self.displayed_position = 0 |
| 326 | self.nhidden_last_display = 0 | 282 | self.nhidden_last_display = 0 |
| 327 | self.selected_dicom = None | 283 | self.selected_dicom = None |
| @@ -359,14 +315,10 @@ class BitmapPreviewSeries(wx.Panel): | @@ -359,14 +315,10 @@ class BitmapPreviewSeries(wx.Panel): | ||
| 359 | for j in xrange(NCOLS): | 315 | for j in xrange(NCOLS): |
| 360 | p = Preview(self) | 316 | p = Preview(self) |
| 361 | p.Bind(EVT_PREVIEW_CLICK, self.OnSelect) | 317 | p.Bind(EVT_PREVIEW_CLICK, self.OnSelect) |
| 362 | - #if (i == j == 0): | ||
| 363 | - #self._show_shadow(p) | ||
| 364 | - #p.Hide() | 318 | + |
| 365 | self.previews.append(p) | 319 | self.previews.append(p) |
| 366 | self.grid.Add(p, 1, flag=wx.EXPAND) | 320 | self.grid.Add(p, 1, flag=wx.EXPAND) |
| 367 | 321 | ||
| 368 | - #def _show_shadow(self, preview): | ||
| 369 | - # preview.ShowShadow() | ||
| 370 | 322 | ||
| 371 | def _bind_events(self): | 323 | def _bind_events(self): |
| 372 | # When the user scrolls the window | 324 | # When the user scrolls the window |
| @@ -375,7 +327,6 @@ class BitmapPreviewSeries(wx.Panel): | @@ -375,7 +327,6 @@ class BitmapPreviewSeries(wx.Panel): | ||
| 375 | 327 | ||
| 376 | def _bind_pub_sub_events(self): | 328 | def _bind_pub_sub_events(self): |
| 377 | Publisher.subscribe(self.RemovePanel, 'Remove preview panel') | 329 | Publisher.subscribe(self.RemovePanel, 'Remove preview panel') |
| 378 | - #Publisher.subscribe(self.GetBmpInfoIdByOrder, 'Set bitmap in thumbnail') | ||
| 379 | 330 | ||
| 380 | def OnSelect(self, evt): | 331 | def OnSelect(self, evt): |
| 381 | my_evt = SerieEvent(myEVT_CLICK_SERIE, self.GetId()) | 332 | my_evt = SerieEvent(myEVT_CLICK_SERIE, self.GetId()) |
| @@ -393,7 +344,6 @@ class BitmapPreviewSeries(wx.Panel): | @@ -393,7 +344,6 @@ class BitmapPreviewSeries(wx.Panel): | ||
| 393 | evt.Skip() | 344 | evt.Skip() |
| 394 | 345 | ||
| 395 | def SetBitmapFiles(self, data): | 346 | def SetBitmapFiles(self, data): |
| 396 | - #self.files = data | ||
| 397 | self.files = [] | 347 | self.files = [] |
| 398 | 348 | ||
| 399 | bitmap = bitmap_reader.BitmapData() | 349 | bitmap = bitmap_reader.BitmapData() |
| @@ -431,65 +381,6 @@ class BitmapPreviewSeries(wx.Panel): | @@ -431,65 +381,6 @@ class BitmapPreviewSeries(wx.Panel): | ||
| 431 | 381 | ||
| 432 | if p.IsShown(): | 382 | if p.IsShown(): |
| 433 | p.bitmap_info.pos = n | 383 | p.bitmap_info.pos = n |
| 434 | - | ||
| 435 | - #def GetBmpInfoIdByOrder(self, pub_sub): | ||
| 436 | - # order = pub_sub.data | ||
| 437 | - # | ||
| 438 | - # for p in self.previews: | ||
| 439 | - # if p.bitmap_info != None: | ||
| 440 | - # if p.select_on: | ||
| 441 | - # p.select_on = False | ||
| 442 | - # p.selected = False | ||
| 443 | - | ||
| 444 | - # c = (PREVIEW_BACKGROUND) | ||
| 445 | - # p.SetBackgroundColour(c) | ||
| 446 | - | ||
| 447 | - | ||
| 448 | - # for p in self.previews: | ||
| 449 | - # if p.bitmap_info != None: | ||
| 450 | - # if p.bitmap_info.pos == order: | ||
| 451 | - | ||
| 452 | - # p.select_on = True | ||
| 453 | - # p.selected = True | ||
| 454 | - | ||
| 455 | - # p.Select() | ||
| 456 | - | ||
| 457 | - # # Generating a EVT_PREVIEW_CLICK event | ||
| 458 | - # my_evt = SerieEvent(myEVT_PREVIEW_CLICK, p.GetId()) | ||
| 459 | - | ||
| 460 | - # my_evt.SetSelectedID(p.bitmap_info.id) | ||
| 461 | - # my_evt.SetItemData(p.bitmap_info.data) | ||
| 462 | - | ||
| 463 | - # my_evt.SetShiftStatus(False) | ||
| 464 | - # my_evt.SetEventObject(p) | ||
| 465 | - # self.GetEventHandler().ProcessEvent(my_evt) | ||
| 466 | - | ||
| 467 | - | ||
| 468 | - # #c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) | ||
| 469 | - # #p.SetBackgroundColour(c) | ||
| 470 | - | ||
| 471 | - #return p.id | ||
| 472 | - | ||
| 473 | - #def SetPatientGroups(self, patient): | ||
| 474 | - # self.files = [] | ||
| 475 | - # self.displayed_position = 0 | ||
| 476 | - # self.nhidden_last_display = 0 | ||
| 477 | - # group_list = patient.GetGroups() | ||
| 478 | - # self.group_list = group_list | ||
| 479 | - # n = 0 | ||
| 480 | - # for group in group_list: | ||
| 481 | - # info = BitmapInfo((group.dicom.patient.id, | ||
| 482 | - # group.dicom.acquisition.serie_number), | ||
| 483 | - # group.dicom, | ||
| 484 | - # group.title, | ||
| 485 | - # _("%d images") %(group.nslices)) | ||
| 486 | - # self.files.append(info) | ||
| 487 | - # n+=1 | ||
| 488 | - # scroll_range = len(self.files)/NCOLS | ||
| 489 | - # if scroll_range * NCOLS < len(self.files): | ||
| 490 | - # scroll_range +=1 | ||
| 491 | - # self.scroll.SetScrollbar(0, NROWS, scroll_range, NCOLS) | ||
| 492 | - # self._display_previews() | ||
| 493 | 384 | ||
| 494 | 385 | ||
| 495 | def _display_previews(self): | 386 | def _display_previews(self): |
| @@ -767,233 +658,3 @@ class SingleImagePreview(wx.Panel): | @@ -767,233 +658,3 @@ class SingleImagePreview(wx.Panel): | ||
| 767 | 658 | ||
| 768 | # Setting slider position | 659 | # Setting slider position |
| 769 | self.slider.SetValue(index) | 660 | self.slider.SetValue(index) |
| 770 | - | ||
| 771 | - | ||
| 772 | -#class BitmapPreviewSlice(wx.Panel): | ||
| 773 | -# def __init__(self, parent): | ||
| 774 | -# super(BitmapPreviewSlice, self).__init__(parent) | ||
| 775 | -# # TODO: 3 pixels between the previews is a good idea? | ||
| 776 | -# # I have to test. | ||
| 777 | -# self.displayed_position = 0 | ||
| 778 | -# self.nhidden_last_display = 0 | ||
| 779 | -# self.selected_dicom = None | ||
| 780 | -# self.selected_panel = None | ||
| 781 | -# self.first_selection = None | ||
| 782 | -# self.last_selection = None | ||
| 783 | -# self._init_ui() | ||
| 784 | -# | ||
| 785 | -# def _init_ui(self): | ||
| 786 | -# scroll = wx.ScrollBar(self, -1, style=wx.SB_VERTICAL) | ||
| 787 | -# self.scroll = scroll | ||
| 788 | -# | ||
| 789 | -# self.grid = wx.GridSizer(rows=NROWS, cols=NCOLS, vgap=3, hgap=3) | ||
| 790 | -# | ||
| 791 | -# sizer = wx.BoxSizer(wx.HORIZONTAL) | ||
| 792 | -# sizer.AddSizer(self.grid, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) | ||
| 793 | -# | ||
| 794 | -# background_sizer = wx.BoxSizer(wx.HORIZONTAL) | ||
| 795 | -# background_sizer.AddSizer(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) | ||
| 796 | -# background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) | ||
| 797 | -# self.SetSizer(background_sizer) | ||
| 798 | -# background_sizer.Fit(self) | ||
| 799 | -# | ||
| 800 | -# self.Layout() | ||
| 801 | -# self.Update() | ||
| 802 | -# self.SetAutoLayout(1) | ||
| 803 | -# | ||
| 804 | -# self.sizer = background_sizer | ||
| 805 | -# | ||
| 806 | -# self._Add_Panels_Preview() | ||
| 807 | -# self._bind_events() | ||
| 808 | -# | ||
| 809 | -# def _Add_Panels_Preview(self): | ||
| 810 | -# self.previews = [] | ||
| 811 | -# for i in xrange(NROWS): | ||
| 812 | -# for j in xrange(NCOLS): | ||
| 813 | -# p = Preview(self) | ||
| 814 | -# p.Bind(EVT_PREVIEW_CLICK, self.OnPreviewClick) | ||
| 815 | -# #p.Hide() | ||
| 816 | -# self.previews.append(p) | ||
| 817 | -# self.grid.Add(p, 1, flag=wx.EXPAND) | ||
| 818 | -# | ||
| 819 | -# def _bind_events(self): | ||
| 820 | -# # When the user scrolls the window | ||
| 821 | -# self.Bind(wx.EVT_SCROLL, self.OnScroll) | ||
| 822 | -# self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel) | ||
| 823 | -# | ||
| 824 | -# def SetDicomDirectory(self, directory): | ||
| 825 | -# utils.debug("Setting Dicom Directory %s" % directory) | ||
| 826 | -# self.directory = directory | ||
| 827 | -# self.series = dicom_reader.GetSeries(directory)[0] | ||
| 828 | -# | ||
| 829 | -# def SetPatientGroups(self, patient): | ||
| 830 | -# self.group_list = patient.GetGroups() | ||
| 831 | -# | ||
| 832 | -# | ||
| 833 | -# #def SetDicomSerie(self, pos): | ||
| 834 | -# # self.files = [] | ||
| 835 | -# # self.displayed_position = 0 | ||
| 836 | -# # self.nhidden_last_display = 0 | ||
| 837 | -# # group = self.group_list[pos] | ||
| 838 | -# # self.group = group | ||
| 839 | -# # #dicom_files = group.GetList() | ||
| 840 | -# # dicom_files = group.GetHandSortedList() | ||
| 841 | -# # n = 0 | ||
| 842 | -# # for dicom in dicom_files: | ||
| 843 | -# # info = BitmapInfo(n, dicom, | ||
| 844 | -# # _("Image %d") % (dicom.image.number), | ||
| 845 | -# # "%.2f" % (dicom.image.position[2])) | ||
| 846 | -# # self.files.append(info) | ||
| 847 | -# # n+=1 | ||
| 848 | -# | ||
| 849 | -# # scroll_range = len(self.files)/NCOLS | ||
| 850 | -# # if scroll_range * NCOLS < len(self.files): | ||
| 851 | -# # scroll_range +=1 | ||
| 852 | -# # self.scroll.SetScrollbar(0, NROWS, scroll_range, NCOLS) | ||
| 853 | -# | ||
| 854 | -# # self._display_previews() | ||
| 855 | -# | ||
| 856 | -# #def SetDicomGroup(self, group): | ||
| 857 | -# # self.files = [] | ||
| 858 | -# # self.displayed_position = 0 | ||
| 859 | -# # self.nhidden_last_display = 0 | ||
| 860 | -# # #dicom_files = group.GetList() | ||
| 861 | -# # dicom_files = group.GetHandSortedList() | ||
| 862 | -# # n = 0 | ||
| 863 | -# # for dicom in dicom_files: | ||
| 864 | -# # info = BitmapInfo(n, dicom, | ||
| 865 | -# # _("Image %d") % (dicom.image.number), | ||
| 866 | -# # "%.2f" % (dicom.image.position[2]), | ||
| 867 | -# # ) | ||
| 868 | -# # self.files.append(info) | ||
| 869 | -# # n+=1 | ||
| 870 | -# | ||
| 871 | -# # scroll_range = len(self.files)/NCOLS | ||
| 872 | -# # if scroll_range * NCOLS < len(self.files): | ||
| 873 | -# # scroll_range +=1 | ||
| 874 | -# # self.scroll.SetScrollbar(0, NROWS, scroll_range, NCOLS) | ||
| 875 | -# | ||
| 876 | -# # self._display_previews() | ||
| 877 | -# | ||
| 878 | -# #def SetDicomGroup(self, group): | ||
| 879 | -# # self.files = [] | ||
| 880 | -# # self.displayed_position = 0 | ||
| 881 | -# # self.nhidden_last_display = 0 | ||
| 882 | -# # #dicom_files = group.GetList() | ||
| 883 | -# # dicom_files = group.GetHandSortedList() | ||
| 884 | -# # n = 0 | ||
| 885 | -# # for dicom in dicom_files: | ||
| 886 | -# # info = BitmapInfo(n, dicom, | ||
| 887 | -# # _("Image %d") % (dicom.image.number), | ||
| 888 | -# # "%.2f" % (dicom.image.position[2]), | ||
| 889 | -# # ) | ||
| 890 | -# # self.files.append(info) | ||
| 891 | -# # n+=1 | ||
| 892 | -# | ||
| 893 | -# # scroll_range = len(self.files)/NCOLS | ||
| 894 | -# # if scroll_range * NCOLS < len(self.files): | ||
| 895 | -# # scroll_range +=1 | ||
| 896 | -# # self.scroll.SetScrollbar(0, NROWS, scroll_range, NCOLS) | ||
| 897 | -# | ||
| 898 | -# # self._display_previews() | ||
| 899 | -# | ||
| 900 | -# | ||
| 901 | -# def _display_previews(self): | ||
| 902 | -# initial = self.displayed_position * NCOLS | ||
| 903 | -# final = initial + NUM_PREVIEWS | ||
| 904 | -# if len(self.files) < final: | ||
| 905 | -# for i in xrange(final-len(self.files)): | ||
| 906 | -# try: | ||
| 907 | -# self.previews[-i-1].Hide() | ||
| 908 | -# except IndexError: | ||
| 909 | -# utils.debug("doesn't exist!") | ||
| 910 | -# self.nhidden_last_display = final-len(self.files) | ||
| 911 | -# else: | ||
| 912 | -# if self.nhidden_last_display: | ||
| 913 | -# for i in xrange(self.nhidden_last_display): | ||
| 914 | -# try: | ||
| 915 | -# self.previews[-i-1].Show() | ||
| 916 | -# except IndexError: | ||
| 917 | -# utils.debug("doesn't exist!") | ||
| 918 | -# self.nhidden_last_display = 0 | ||
| 919 | -# | ||
| 920 | -# for f, p in zip(self.files[initial:final], self.previews): | ||
| 921 | -# p.SetBitmapToPreview(f) | ||
| 922 | -# if f.selected: | ||
| 923 | -# self.selected_panel = p | ||
| 924 | -# #p.interactor.Render() | ||
| 925 | -# | ||
| 926 | -# for f, p in zip(self.files[initial:final], self.previews): | ||
| 927 | -# p.Show() | ||
| 928 | -# | ||
| 929 | -# def OnPreviewClick(self, evt): | ||
| 930 | -# | ||
| 931 | -# dicom_id = evt.GetSelectID() | ||
| 932 | -# | ||
| 933 | -# if self.first_selection is None: | ||
| 934 | -# self.first_selection = dicom_id | ||
| 935 | -# | ||
| 936 | -# if self.last_selection is None: | ||
| 937 | -# self.last_selection = dicom_id | ||
| 938 | -# | ||
| 939 | -# | ||
| 940 | -# if evt.GetPressedShift(): | ||
| 941 | -# | ||
| 942 | -# if dicom_id < self.first_selection and dicom_id < self.last_selection: | ||
| 943 | -# self.first_selection = dicom_id | ||
| 944 | -# else: | ||
| 945 | -# self.last_selection = dicom_id | ||
| 946 | -# else: | ||
| 947 | -# self.first_selection = dicom_id | ||
| 948 | -# self.last_selection = dicom_id | ||
| 949 | -# | ||
| 950 | -# for i in xrange(len(self.files)): | ||
| 951 | -# | ||
| 952 | -# if i == dicom_id: | ||
| 953 | -# self.files[i].selected = True | ||
| 954 | -# else: | ||
| 955 | -# self.files[i].selected = False | ||
| 956 | -# | ||
| 957 | -# | ||
| 958 | -# my_evt = SerieEvent(myEVT_CLICK_SLICE, self.GetId()) | ||
| 959 | -# my_evt.SetSelectedID(evt.GetSelectID()) | ||
| 960 | -# my_evt.SetItemData(evt.GetItemData()) | ||
| 961 | -# | ||
| 962 | -# if self.selected_dicom: | ||
| 963 | -# self.selected_dicom.selected = self.selected_dicom is \ | ||
| 964 | -# evt.GetEventObject().bitmap_info | ||
| 965 | -# self.selected_panel.select_on = self.selected_panel is evt.GetEventObject() | ||
| 966 | -# | ||
| 967 | -# if self.first_selection != self.last_selection: | ||
| 968 | -# for i in xrange(len(self.files)): | ||
| 969 | -# if i >= self.first_selection and i <= self.last_selection: | ||
| 970 | -# self.files[i].selected = True | ||
| 971 | -# else: | ||
| 972 | -# self.files[i].selected = False | ||
| 973 | -# | ||
| 974 | -# else: | ||
| 975 | -# self.selected_panel.Select() | ||
| 976 | -# | ||
| 977 | -# self._display_previews() | ||
| 978 | -# self.selected_panel = evt.GetEventObject() | ||
| 979 | -# self.selected_dicom = self.selected_panel.bitmap_info | ||
| 980 | -# self.GetEventHandler().ProcessEvent(my_evt) | ||
| 981 | -# | ||
| 982 | -# #Publisher.sendMessage("Selected Import Images", [self.first_selection, \ | ||
| 983 | -# # self.last_selection]) | ||
| 984 | -# | ||
| 985 | -# def OnScroll(self, evt=None): | ||
| 986 | -# if evt: | ||
| 987 | -# if self.displayed_position != evt.GetPosition(): | ||
| 988 | -# self.displayed_position = evt.GetPosition() | ||
| 989 | -# else: | ||
| 990 | -# if self.displayed_position != self.scroll.GetThumbPosition(): | ||
| 991 | -# self.displayed_position = self.scroll.GetThumbPosition() | ||
| 992 | -# self._display_previews() | ||
| 993 | -# | ||
| 994 | -# def OnWheel(self, evt): | ||
| 995 | -# d = evt.GetWheelDelta() / evt.GetWheelRotation() | ||
| 996 | -# self.scroll.SetThumbPosition(self.scroll.GetThumbPosition() - d) | ||
| 997 | -# self.OnScroll() | ||
| 998 | - | ||
| 999 | - |
invesalius/gui/dialogs.py
| @@ -1686,10 +1686,17 @@ class ReorientImageDialog(wx.Dialog): | @@ -1686,10 +1686,17 @@ class ReorientImageDialog(wx.Dialog): | ||
| 1686 | 1686 | ||
| 1687 | 1687 | ||
| 1688 | class ImportBitmapParameters(wx.Dialog): | 1688 | class ImportBitmapParameters(wx.Dialog): |
| 1689 | + from os import sys | ||
| 1689 | 1690 | ||
| 1690 | def __init__(self): | 1691 | def __init__(self): |
| 1691 | pre = wx.PreDialog() | 1692 | pre = wx.PreDialog() |
| 1692 | - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Parameters"),size=wx.Size(380,230),\ | 1693 | + |
| 1694 | + if sys.platform == 'win32': | ||
| 1695 | + size=wx.Size(380,180) | ||
| 1696 | + else: | ||
| 1697 | + size=wx.Size(380,210) | ||
| 1698 | + | ||
| 1699 | + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Create project from bitmap"),size=wx.Size(380,220),\ | ||
| 1693 | style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP) | 1700 | style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP) |
| 1694 | 1701 | ||
| 1695 | self.interval = 0 | 1702 | self.interval = 0 |
| @@ -1710,27 +1717,31 @@ class ImportBitmapParameters(wx.Dialog): | @@ -1710,27 +1717,31 @@ class ImportBitmapParameters(wx.Dialog): | ||
| 1710 | | wx.CLIP_CHILDREN | 1717 | | wx.CLIP_CHILDREN |
| 1711 | | wx.FULL_REPAINT_ON_RESIZE) | 1718 | | wx.FULL_REPAINT_ON_RESIZE) |
| 1712 | 1719 | ||
| 1713 | - gbs_principal = self.gbs = wx.GridBagSizer(3,1) | 1720 | + gbs_principal = self.gbs = wx.GridBagSizer(4,1) |
| 1721 | + | ||
| 1722 | + gbs = self.gbs = wx.GridBagSizer(5, 2) | ||
| 1723 | + | ||
| 1724 | + flag_labels = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | ||
| 1714 | 1725 | ||
| 1715 | - gbs = self.gbs = wx.GridBagSizer(4, 2) | ||
| 1716 | - | ||
| 1717 | stx_name = wx.StaticText(p, -1, _(u"Project name:")) | 1726 | stx_name = wx.StaticText(p, -1, _(u"Project name:")) |
| 1718 | tx_name = self.tx_name = wx.TextCtrl(p, -1, "InVesalius Bitmap", size=wx.Size(220,-1)) | 1727 | tx_name = self.tx_name = wx.TextCtrl(p, -1, "InVesalius Bitmap", size=wx.Size(220,-1)) |
| 1719 | 1728 | ||
| 1720 | - stx_orientation = wx.StaticText(p, -1, _(u"Slices orientation:")) | 1729 | + stx_orientation = wx.StaticText(p, -1, _(u"Slices orientation:"),) |
| 1721 | cb_orientation_options = [_(u'Axial'), _(u'Coronal'), _(u'Sagital')] | 1730 | cb_orientation_options = [_(u'Axial'), _(u'Coronal'), _(u'Sagital')] |
| 1722 | cb_orientation = self.cb_orientation = wx.ComboBox(p, value="Axial", choices=cb_orientation_options,\ | 1731 | cb_orientation = self.cb_orientation = wx.ComboBox(p, value="Axial", choices=cb_orientation_options,\ |
| 1723 | size=wx.Size(160,-1), style=wx.CB_DROPDOWN|wx.CB_READONLY) | 1732 | size=wx.Size(160,-1), style=wx.CB_DROPDOWN|wx.CB_READONLY) |
| 1724 | 1733 | ||
| 1725 | stx_spacing = wx.StaticText(p, -1, _(u"Spacing (mm):")) | 1734 | stx_spacing = wx.StaticText(p, -1, _(u"Spacing (mm):")) |
| 1726 | 1735 | ||
| 1727 | - gbs.Add(stx_name, (0,0)) | 1736 | + gbs.Add(stx_name, (0,0), flag=flag_labels) |
| 1728 | gbs.Add(tx_name, (0,1)) | 1737 | gbs.Add(tx_name, (0,1)) |
| 1738 | + gbs.AddStretchSpacer((1,0)) | ||
| 1729 | 1739 | ||
| 1730 | - gbs.Add(stx_orientation, (1,0)) | ||
| 1731 | - gbs.Add(cb_orientation, (1,1)) | 1740 | + gbs.Add(stx_orientation, (2,0), flag=flag_labels) |
| 1741 | + gbs.Add(cb_orientation, (2,1)) | ||
| 1732 | 1742 | ||
| 1733 | - gbs.Add(stx_spacing, (2,0)) | 1743 | + gbs.Add(stx_spacing, (3,0)) |
| 1744 | + gbs.AddStretchSpacer((4,0)) | ||
| 1734 | 1745 | ||
| 1735 | #--- spacing -------------- | 1746 | #--- spacing -------------- |
| 1736 | gbs_spacing = wx.GridBagSizer(2, 6) | 1747 | gbs_spacing = wx.GridBagSizer(2, 6) |
| @@ -1739,6 +1750,7 @@ class ImportBitmapParameters(wx.Dialog): | @@ -1739,6 +1750,7 @@ class ImportBitmapParameters(wx.Dialog): | ||
| 1739 | fsp_spacing_x = self.fsp_spacing_x = FS.FloatSpin(p, -1, min_val=0,\ | 1750 | fsp_spacing_x = self.fsp_spacing_x = FS.FloatSpin(p, -1, min_val=0,\ |
| 1740 | increment=0.25, value=1.0, digits=8) | 1751 | increment=0.25, value=1.0, digits=8) |
| 1741 | 1752 | ||
| 1753 | + | ||
| 1742 | stx_spacing_y = stx_spacing_y = wx.StaticText(p, -1, _(u"Y:")) | 1754 | stx_spacing_y = stx_spacing_y = wx.StaticText(p, -1, _(u"Y:")) |
| 1743 | fsp_spacing_y = self.fsp_spacing_y = FS.FloatSpin(p, -1, min_val=0,\ | 1755 | fsp_spacing_y = self.fsp_spacing_y = FS.FloatSpin(p, -1, min_val=0,\ |
| 1744 | increment=0.25, value=1.0, digits=8) | 1756 | increment=0.25, value=1.0, digits=8) |
| @@ -1762,33 +1774,34 @@ class ImportBitmapParameters(wx.Dialog): | @@ -1762,33 +1774,34 @@ class ImportBitmapParameters(wx.Dialog): | ||
| 1762 | except(AttributeError): | 1774 | except(AttributeError): |
| 1763 | pass | 1775 | pass |
| 1764 | 1776 | ||
| 1765 | - gbs_spacing.Add(stx_spacing_x, (0,0)) | 1777 | + gbs_spacing.Add(stx_spacing_x, (0,0), flag=flag_labels) |
| 1766 | gbs_spacing.Add(fsp_spacing_x, (0,1)) | 1778 | gbs_spacing.Add(fsp_spacing_x, (0,1)) |
| 1767 | 1779 | ||
| 1768 | - gbs_spacing.Add(stx_spacing_y, (0,2)) | 1780 | + gbs_spacing.Add(stx_spacing_y, (0,2), flag=flag_labels) |
| 1769 | gbs_spacing.Add(fsp_spacing_y, (0,3)) | 1781 | gbs_spacing.Add(fsp_spacing_y, (0,3)) |
| 1770 | 1782 | ||
| 1771 | - gbs_spacing.Add(stx_spacing_z, (0,4)) | 1783 | + gbs_spacing.Add(stx_spacing_z, (0,4), flag=flag_labels) |
| 1772 | gbs_spacing.Add(fsp_spacing_z, (0,5)) | 1784 | gbs_spacing.Add(fsp_spacing_z, (0,5)) |
| 1773 | 1785 | ||
| 1774 | #----- buttons ------------------------ | 1786 | #----- buttons ------------------------ |
| 1775 | - gbs_button = wx.GridBagSizer(1, 4) | 1787 | + gbs_button = wx.GridBagSizer(2, 4) |
| 1776 | 1788 | ||
| 1777 | btn_ok = self.btn_ok= wx.Button(p, wx.ID_OK) | 1789 | btn_ok = self.btn_ok= wx.Button(p, wx.ID_OK) |
| 1778 | btn_ok.SetDefault() | 1790 | btn_ok.SetDefault() |
| 1779 | 1791 | ||
| 1780 | btn_cancel = wx.Button(p, wx.ID_CANCEL) | 1792 | btn_cancel = wx.Button(p, wx.ID_CANCEL) |
| 1781 | 1793 | ||
| 1794 | + gbs_button.AddStretchSpacer((0,2)) | ||
| 1782 | gbs_button.Add(btn_cancel, (1,2)) | 1795 | gbs_button.Add(btn_cancel, (1,2)) |
| 1783 | gbs_button.Add(btn_ok, (1,3)) | 1796 | gbs_button.Add(btn_ok, (1,3)) |
| 1784 | 1797 | ||
| 1785 | - | ||
| 1786 | - gbs_principal.Add(gbs, (0,0)) | ||
| 1787 | - gbs_principal.Add(gbs_spacing, (1,0)) | ||
| 1788 | - gbs_principal.Add(gbs_button, (2,0), flag = wx.ALIGN_RIGHT) | 1798 | + gbs_principal.AddSizer(gbs, (0,0), flag = wx.ALL|wx.EXPAND) |
| 1799 | + gbs_principal.AddSizer(gbs_spacing, (1,0), flag=wx.ALL|wx.EXPAND) | ||
| 1800 | + gbs_principal.AddStretchSpacer((2,0)) | ||
| 1801 | + gbs_principal.AddSizer(gbs_button, (3,0), flag = wx.ALIGN_RIGHT) | ||
| 1789 | 1802 | ||
| 1790 | box = wx.BoxSizer() | 1803 | box = wx.BoxSizer() |
| 1791 | - box.Add(gbs_principal, 1, wx.ALL|wx.EXPAND, 10) | 1804 | + box.AddSizer(gbs_principal, 1, wx.ALL|wx.EXPAND, 10) |
| 1792 | 1805 | ||
| 1793 | p.SetSizer(box) | 1806 | p.SetSizer(box) |
| 1794 | 1807 | ||
| @@ -1820,10 +1833,8 @@ class ImportBitmapParameters(wx.Dialog): | @@ -1820,10 +1833,8 @@ class ImportBitmapParameters(wx.Dialog): | ||
| 1820 | 1833 | ||
| 1821 | def BitmapNotSameSize(): | 1834 | def BitmapNotSameSize(): |
| 1822 | 1835 | ||
| 1823 | - dlg = wx.MessageDialog(None,_("All bitmaps files must be the same width and height size"), 'Error',\ | ||
| 1824 | - wx.OK | wx.ICON_ERROR | ||
| 1825 | - #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION | ||
| 1826 | - ) | 1836 | + dlg = wx.MessageDialog(None,_("All bitmaps files must be the same \n width and height size."), 'Error',\ |
| 1837 | + wx.OK | wx.ICON_ERROR) | ||
| 1827 | 1838 | ||
| 1828 | dlg.ShowModal() | 1839 | dlg.ShowModal() |
| 1829 | dlg.Destroy() | 1840 | dlg.Destroy() |
invesalius/gui/import_bitmap_panel.py
| @@ -58,8 +58,7 @@ class SelectEvent(wx.PyCommandEvent): | @@ -58,8 +58,7 @@ class SelectEvent(wx.PyCommandEvent): | ||
| 58 | 58 | ||
| 59 | class Panel(wx.Panel): | 59 | class Panel(wx.Panel): |
| 60 | def __init__(self, parent): | 60 | def __init__(self, parent): |
| 61 | - wx.Panel.__init__(self, parent, pos=wx.Point(5, 5))#, | ||
| 62 | - #size=wx.Size(280, 656)) | 61 | + wx.Panel.__init__(self, parent, pos=wx.Point(5, 5)) |
| 63 | 62 | ||
| 64 | sizer = wx.BoxSizer(wx.VERTICAL) | 63 | sizer = wx.BoxSizer(wx.VERTICAL) |
| 65 | sizer.Add(InnerPanel(self), 1, wx.EXPAND|wx.GROW|wx.ALL, 5) | 64 | sizer.Add(InnerPanel(self), 1, wx.EXPAND|wx.GROW|wx.ALL, 5) |
| @@ -75,8 +74,7 @@ class Panel(wx.Panel): | @@ -75,8 +74,7 @@ class Panel(wx.Panel): | ||
| 75 | # Inner fold panel | 74 | # Inner fold panel |
| 76 | class InnerPanel(wx.Panel): | 75 | class InnerPanel(wx.Panel): |
| 77 | def __init__(self, parent): | 76 | def __init__(self, parent): |
| 78 | - wx.Panel.__init__(self, parent, pos=wx.Point(5, 5))#, | ||
| 79 | - #size=wx.Size(680, 656)) | 77 | + wx.Panel.__init__(self, parent, pos=wx.Point(5, 5)) |
| 80 | 78 | ||
| 81 | self.patients = [] | 79 | self.patients = [] |
| 82 | self.first_image_selection = None | 80 | self.first_image_selection = None |
| @@ -140,26 +138,12 @@ class InnerPanel(wx.Panel): | @@ -140,26 +138,12 @@ class InnerPanel(wx.Panel): | ||
| 140 | self.last_image_selection = pubsub_evt.data[1] | 138 | self.last_image_selection = pubsub_evt.data[1] |
| 141 | 139 | ||
| 142 | def _bind_events(self): | 140 | def _bind_events(self): |
| 143 | - self.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) | ||
| 144 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) | 141 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) |
| 145 | self.Bind(EVT_SELECT_PATIENT, self.OnSelectPatient) | 142 | self.Bind(EVT_SELECT_PATIENT, self.OnSelectPatient) |
| 146 | self.btn_ok.Bind(wx.EVT_BUTTON, self.OnClickOk) | 143 | self.btn_ok.Bind(wx.EVT_BUTTON, self.OnClickOk) |
| 147 | self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnClickCancel) | 144 | self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnClickCancel) |
| 148 | self.text_panel.Bind(EVT_SELECT_SERIE_TEXT, self.OnDblClickTextPanel) | 145 | self.text_panel.Bind(EVT_SELECT_SERIE_TEXT, self.OnDblClickTextPanel) |
| 149 | 146 | ||
| 150 | - def OnSelectSerie(self, evt): | ||
| 151 | - #patient_id, serie_number = evt.GetSelectID() | ||
| 152 | - #self.text_panel.SelectSerie(evt.GetSelectID()) | ||
| 153 | - #for patient in self.patients: | ||
| 154 | - # if patient_id == patient.GetDicomSample().patient.id: | ||
| 155 | - # for group in patient.GetGroups(): | ||
| 156 | - # if serie_number == group.GetDicomSample().acquisition.serie_number: | ||
| 157 | - # self.image_panel.SetSerie(group) | ||
| 158 | - | ||
| 159 | - pass | ||
| 160 | - | ||
| 161 | - | ||
| 162 | - | ||
| 163 | def OnSelectSlice(self, evt): | 147 | def OnSelectSlice(self, evt): |
| 164 | pass | 148 | pass |
| 165 | 149 | ||
| @@ -175,33 +159,10 @@ class InnerPanel(wx.Panel): | @@ -175,33 +159,10 @@ class InnerPanel(wx.Panel): | ||
| 175 | parm.SetInterval(self.combo_interval.GetSelection()) | 159 | parm.SetInterval(self.combo_interval.GetSelection()) |
| 176 | parm.ShowModal() | 160 | parm.ShowModal() |
| 177 | 161 | ||
| 178 | - group = self.text_panel.GetSelection() | ||
| 179 | - if group: | ||
| 180 | - self.LoadDicom(group) | ||
| 181 | 162 | ||
| 182 | def OnClickCancel(self, evt): | 163 | def OnClickCancel(self, evt): |
| 183 | Publisher.sendMessage("Cancel DICOM load") | 164 | Publisher.sendMessage("Cancel DICOM load") |
| 184 | 165 | ||
| 185 | - def LoadDicom(self, group): | ||
| 186 | - #interval = self.combo_interval.GetSelection() | ||
| 187 | - #if not isinstance(group, dcm.DicomGroup): | ||
| 188 | - # group = max(group.GetGroups(), key=lambda g: g.nslices) | ||
| 189 | - | ||
| 190 | - #slice_amont = group.nslices | ||
| 191 | - #if (self.first_image_selection != None) and (self.first_image_selection != self.last_image_selection): | ||
| 192 | - # slice_amont = (self.last_image_selection) - self.first_image_selection | ||
| 193 | - # slice_amont += 1 | ||
| 194 | - # if slice_amont == 0: | ||
| 195 | - # slice_amont = group.nslices | ||
| 196 | - | ||
| 197 | - #nslices_result = slice_amont / (interval + 1) | ||
| 198 | - #if (nslices_result > 1): | ||
| 199 | - # Publisher.sendMessage('Open DICOM group', (group, interval, | ||
| 200 | - # [self.first_image_selection, self.last_image_selection])) | ||
| 201 | - #else: | ||
| 202 | - # dlg.MissingFilesForReconstruction() | ||
| 203 | - pass | ||
| 204 | - | ||
| 205 | 166 | ||
| 206 | class TextPanel(wx.Panel): | 167 | class TextPanel(wx.Panel): |
| 207 | def __init__(self, parent): | 168 | def __init__(self, parent): |
| @@ -213,7 +174,8 @@ class TextPanel(wx.Panel): | @@ -213,7 +174,8 @@ class TextPanel(wx.Panel): | ||
| 213 | self.idserie_treeitem = {} | 174 | self.idserie_treeitem = {} |
| 214 | self.treeitem_idpatient = {} | 175 | self.treeitem_idpatient = {} |
| 215 | 176 | ||
| 216 | - self.selected_item = None | 177 | + self.selected_items = None |
| 178 | + self.shift_pressed = False | ||
| 217 | 179 | ||
| 218 | self.__init_gui() | 180 | self.__init_gui() |
| 219 | self.__bind_events_wx() | 181 | self.__bind_events_wx() |
| @@ -233,7 +195,7 @@ class TextPanel(wx.Panel): | @@ -233,7 +195,7 @@ class TextPanel(wx.Panel): | ||
| 233 | | wx.TR_ROW_LINES | 195 | | wx.TR_ROW_LINES |
| 234 | | wx.TR_COLUMN_LINES | 196 | | wx.TR_COLUMN_LINES |
| 235 | | wx.TR_FULL_ROW_HIGHLIGHT | 197 | | wx.TR_FULL_ROW_HIGHLIGHT |
| 236 | - | wx.TR_SINGLE | 198 | + | wx.TR_MULTIPLE |
| 237 | | wx.TR_HIDE_ROOT | 199 | | wx.TR_HIDE_ROOT |
| 238 | ) | 200 | ) |
| 239 | 201 | ||
| @@ -250,31 +212,38 @@ class TextPanel(wx.Panel): | @@ -250,31 +212,38 @@ class TextPanel(wx.Panel): | ||
| 250 | self.root = tree.AddRoot(_("InVesalius Database")) | 212 | self.root = tree.AddRoot(_("InVesalius Database")) |
| 251 | self.tree = tree | 213 | self.tree = tree |
| 252 | 214 | ||
| 215 | + | ||
| 216 | + | ||
| 253 | def OnKeyPress(self, evt): | 217 | def OnKeyPress(self, evt): |
| 254 | key_code = evt.GetKeyCode() | 218 | key_code = evt.GetKeyCode() |
| 219 | + | ||
| 255 | if key_code == wx.WXK_DELETE or key_code == wx.WXK_NUMPAD_DELETE: | 220 | if key_code == wx.WXK_DELETE or key_code == wx.WXK_NUMPAD_DELETE: |
| 256 | - if self.selected_item != self.tree.GetRootItem(): | ||
| 257 | - text_item = self.tree.GetItemText(self.selected_item) | ||
| 258 | - | ||
| 259 | - index = bpr.BitmapData().GetIndexByPath(text_item) | ||
| 260 | - | ||
| 261 | - bpr.BitmapData().RemoveFileByPath(text_item) | ||
| 262 | - | ||
| 263 | - data_size = len(bpr.BitmapData().GetData()) | ||
| 264 | - | ||
| 265 | - if index >= 0 and index < data_size: | ||
| 266 | - Publisher.sendMessage('Set bitmap in preview panel', index) | ||
| 267 | - elif index == data_size and data_size > 0: | ||
| 268 | - Publisher.sendMessage('Set bitmap in preview panel', index - 1) | ||
| 269 | - elif data_size == 1: | ||
| 270 | - Publisher.sendMessage('Set bitmap in preview panel', 0) | ||
| 271 | - else: | ||
| 272 | - Publisher.sendMessage('Show black slice in single preview image') | ||
| 273 | - | ||
| 274 | - self.tree.Delete(self.selected_item) | ||
| 275 | - self.tree.Update() | ||
| 276 | - self.tree.Refresh() | ||
| 277 | - Publisher.sendMessage('Remove preview panel', text_item) | 221 | + |
| 222 | + for selected_item in self.selected_items: | ||
| 223 | + | ||
| 224 | + if selected_item != self.tree.GetRootItem(): | ||
| 225 | + text_item = self.tree.GetItemText(selected_item) | ||
| 226 | + | ||
| 227 | + index = bpr.BitmapData().GetIndexByPath(text_item) | ||
| 228 | + | ||
| 229 | + bpr.BitmapData().RemoveFileByPath(text_item) | ||
| 230 | + | ||
| 231 | + data_size = len(bpr.BitmapData().GetData()) | ||
| 232 | + | ||
| 233 | + if index >= 0 and index < data_size: | ||
| 234 | + Publisher.sendMessage('Set bitmap in preview panel', index) | ||
| 235 | + elif index == data_size and data_size > 0: | ||
| 236 | + Publisher.sendMessage('Set bitmap in preview panel', index - 1) | ||
| 237 | + elif data_size == 1: | ||
| 238 | + Publisher.sendMessage('Set bitmap in preview panel', 0) | ||
| 239 | + else: | ||
| 240 | + Publisher.sendMessage('Show black slice in single preview image') | ||
| 241 | + | ||
| 242 | + self.tree.Delete(selected_item) | ||
| 243 | + self.tree.Update() | ||
| 244 | + self.tree.Refresh() | ||
| 245 | + Publisher.sendMessage('Remove preview panel', text_item) | ||
| 246 | + | ||
| 278 | evt.Skip() | 247 | evt.Skip() |
| 279 | 248 | ||
| 280 | def SelectSeries(self, pubsub_evt): | 249 | def SelectSeries(self, pubsub_evt): |
| @@ -288,18 +257,18 @@ class TextPanel(wx.Panel): | @@ -288,18 +257,18 @@ class TextPanel(wx.Panel): | ||
| 288 | self.tree.SetItemText(parent, value[5], 2) | 257 | self.tree.SetItemText(parent, value[5], 2) |
| 289 | 258 | ||
| 290 | tree.Expand(self.root) | 259 | tree.Expand(self.root) |
| 291 | - #tree.SelectItem(parent_select) | ||
| 292 | tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) | 260 | tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) |
| 293 | tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged) | 261 | tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged) |
| 294 | 262 | ||
| 295 | Publisher.sendMessage('Load bitmap into import panel', data) | 263 | Publisher.sendMessage('Load bitmap into import panel', data) |
| 296 | 264 | ||
| 297 | def OnSelChanged(self, evt): | 265 | def OnSelChanged(self, evt): |
| 298 | - item = self.tree.GetSelection() | 266 | + self.selected_items = self.tree.GetSelections() |
| 267 | + item = self.selected_items[-1] | ||
| 268 | + | ||
| 299 | if self._selected_by_user: | 269 | if self._selected_by_user: |
| 300 | - self.selected_item = item | ||
| 301 | - | ||
| 302 | - text_item = self.tree.GetItemText(self.selected_item) | 270 | + |
| 271 | + text_item = self.tree.GetItemText(item) | ||
| 303 | index = bpr.BitmapData().GetIndexByPath(text_item) | 272 | index = bpr.BitmapData().GetIndexByPath(text_item) |
| 304 | Publisher.sendMessage('Set bitmap in preview panel', index) | 273 | Publisher.sendMessage('Set bitmap in preview panel', index) |
| 305 | 274 | ||
| @@ -360,12 +329,8 @@ class ImagePanel(wx.Panel): | @@ -360,12 +329,8 @@ class ImagePanel(wx.Panel): | ||
| 360 | self.SetAutoLayout(1) | 329 | self.SetAutoLayout(1) |
| 361 | 330 | ||
| 362 | def _bind_events(self): | 331 | def _bind_events(self): |
| 363 | - self.text_panel.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) | ||
| 364 | self.text_panel.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) | 332 | self.text_panel.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) |
| 365 | 333 | ||
| 366 | - def OnSelectSerie(self, evt): | ||
| 367 | - evt.Skip() | ||
| 368 | - | ||
| 369 | def OnSelectSlice(self, evt): | 334 | def OnSelectSlice(self, evt): |
| 370 | self.image_panel.bitmap_preview.ShowSlice(evt.GetSelectID()) | 335 | self.image_panel.bitmap_preview.ShowSlice(evt.GetSelectID()) |
| 371 | evt.Skip() | 336 | evt.Skip() |
| @@ -377,16 +342,12 @@ class ImagePanel(wx.Panel): | @@ -377,16 +342,12 @@ class ImagePanel(wx.Panel): | ||
| 377 | class SeriesPanel(wx.Panel): | 342 | class SeriesPanel(wx.Panel): |
| 378 | def __init__(self, parent): | 343 | def __init__(self, parent): |
| 379 | wx.Panel.__init__(self, parent, -1) | 344 | wx.Panel.__init__(self, parent, -1) |
| 380 | - #self.SetBackgroundColour((0,0,0)) | ||
| 381 | 345 | ||
| 382 | self.thumbnail_preview = bpp.BitmapPreviewSeries(self) | 346 | self.thumbnail_preview = bpp.BitmapPreviewSeries(self) |
| 383 | - #self.bitmap_preview = bpp.BitmapPreviewSlice(self) | ||
| 384 | - #self.bitmap_preview.Show(0) | ||
| 385 | - | 347 | + |
| 386 | 348 | ||
| 387 | self.sizer = wx.BoxSizer(wx.HORIZONTAL) | 349 | self.sizer = wx.BoxSizer(wx.HORIZONTAL) |
| 388 | self.sizer.Add(self.thumbnail_preview, 1, wx.EXPAND | wx.ALL, 5) | 350 | self.sizer.Add(self.thumbnail_preview, 1, wx.EXPAND | wx.ALL, 5) |
| 389 | - #self.sizer.Add(self.bitmap_preview, 1, wx.EXPAND | wx.ALL, 5) | ||
| 390 | self.sizer.Fit(self) | 351 | self.sizer.Fit(self) |
| 391 | 352 | ||
| 392 | self.SetSizer(self.sizer) | 353 | self.SetSizer(self.sizer) |
| @@ -399,21 +360,11 @@ class SeriesPanel(wx.Panel): | @@ -399,21 +360,11 @@ class SeriesPanel(wx.Panel): | ||
| 399 | self._bind_gui_evt() | 360 | self._bind_gui_evt() |
| 400 | 361 | ||
| 401 | def __bind_evt(self): | 362 | def __bind_evt(self): |
| 402 | - #Publisher.subscribe(self.ShowDicomSeries, 'Load bitmap preview') | ||
| 403 | - #Publisher.subscribe(self.SetDicomSeries, 'Load group into import panel') | ||
| 404 | Publisher.subscribe(self.SetBitmapFiles, 'Load bitmap into import panel') | 363 | Publisher.subscribe(self.SetBitmapFiles, 'Load bitmap into import panel') |
| 405 | 364 | ||
| 406 | def _bind_gui_evt(self): | 365 | def _bind_gui_evt(self): |
| 407 | self.thumbnail_preview.Bind(bpp.EVT_CLICK_SERIE, self.OnSelectSerie) | 366 | self.thumbnail_preview.Bind(bpp.EVT_CLICK_SERIE, self.OnSelectSerie) |
| 408 | - #self.bitmap_preview.Bind(bpp.EVT_CLICK_SLICE, self.OnSelectSlice) | ||
| 409 | 367 | ||
| 410 | - #def SetDicomSeries(self, pubsub_evt): | ||
| 411 | - # group = pubsub_evt.data | ||
| 412 | - # self.bitmap_preview.SetDicomGroup(group) | ||
| 413 | - # self.bitmap_preview.Show(1) | ||
| 414 | - # self.thumbnail_preview.Show(0) | ||
| 415 | - # self.sizer.Layout() | ||
| 416 | - # self.Update() | ||
| 417 | 368 | ||
| 418 | def GetSelectedImagesRange(self): | 369 | def GetSelectedImagesRange(self): |
| 419 | return [self.bitmap_preview.first_selected, self.dicom_preview_last_selection] | 370 | return [self.bitmap_preview.first_selected, self.dicom_preview_last_selection] |
| @@ -422,11 +373,9 @@ class SeriesPanel(wx.Panel): | @@ -422,11 +373,9 @@ class SeriesPanel(wx.Panel): | ||
| 422 | 373 | ||
| 423 | 374 | ||
| 424 | bitmap = pubsub_evt.data | 375 | bitmap = pubsub_evt.data |
| 425 | - #self.bitmap_preview.Show(0) | ||
| 426 | self.thumbnail_preview.Show(1) | 376 | self.thumbnail_preview.Show(1) |
| 427 | 377 | ||
| 428 | self.thumbnail_preview.SetBitmapFiles(bitmap) | 378 | self.thumbnail_preview.SetBitmapFiles(bitmap) |
| 429 | - #self.bitmap_preview.SetPatientGroups(patient) | ||
| 430 | 379 | ||
| 431 | self.Update() | 380 | self.Update() |
| 432 | 381 | ||
| @@ -437,9 +386,6 @@ class SeriesPanel(wx.Panel): | @@ -437,9 +386,6 @@ class SeriesPanel(wx.Panel): | ||
| 437 | my_evt.SetItemData(evt.GetItemData()) | 386 | my_evt.SetItemData(evt.GetItemData()) |
| 438 | self.GetEventHandler().ProcessEvent(my_evt) | 387 | self.GetEventHandler().ProcessEvent(my_evt) |
| 439 | 388 | ||
| 440 | - #self.bitmap_preview.SetDicomGroup(data) | ||
| 441 | - #self.bitmap_preview.Show(1) | ||
| 442 | - #self.thumbnail_preview.Show(0) | ||
| 443 | self.sizer.Layout() | 389 | self.sizer.Layout() |
| 444 | self.Show() | 390 | self.Show() |
| 445 | self.Update() | 391 | self.Update() |
| @@ -451,12 +397,6 @@ class SeriesPanel(wx.Panel): | @@ -451,12 +397,6 @@ class SeriesPanel(wx.Panel): | ||
| 451 | self.GetEventHandler().ProcessEvent(my_evt) | 397 | self.GetEventHandler().ProcessEvent(my_evt) |
| 452 | 398 | ||
| 453 | 399 | ||
| 454 | - #def ShowDicomSeries(self, pubsub_evt): | ||
| 455 | - # patient = pubsub_evt.data | ||
| 456 | - # if isinstance(patient, dcm.PatientGroup): | ||
| 457 | - # self.thumbnail_preview.SetPatientGroups(patient) | ||
| 458 | - # self.bitmap_preview.SetPatientGroups(patient) | ||
| 459 | - | ||
| 460 | 400 | ||
| 461 | class SlicePanel(wx.Panel): | 401 | class SlicePanel(wx.Panel): |
| 462 | def __init__(self, parent): | 402 | def __init__(self, parent): |
| @@ -465,8 +405,6 @@ class SlicePanel(wx.Panel): | @@ -465,8 +405,6 @@ class SlicePanel(wx.Panel): | ||
| 465 | self.__bind_evt() | 405 | self.__bind_evt() |
| 466 | 406 | ||
| 467 | def __bind_evt(self): | 407 | def __bind_evt(self): |
| 468 | - #Publisher.subscribe(self.ShowDicomSeries, 'Load bitmap preview') | ||
| 469 | - #Publisher.subscribe(self.SetDicomSeries, 'Load group into import panel') | ||
| 470 | Publisher.subscribe(self.SetBitmapFiles, 'Load bitmap into import panel') | 408 | Publisher.subscribe(self.SetBitmapFiles, 'Load bitmap into import panel') |
| 471 | 409 | ||
| 472 | def __init_gui(self): | 410 | def __init_gui(self): |
| @@ -487,17 +425,3 @@ class SlicePanel(wx.Panel): | @@ -487,17 +425,3 @@ class SlicePanel(wx.Panel): | ||
| 487 | self.bitmap_preview.SetBitmapFiles(data) | 425 | self.bitmap_preview.SetBitmapFiles(data) |
| 488 | self.sizer.Layout() | 426 | self.sizer.Layout() |
| 489 | self.Update() | 427 | self.Update() |
| 490 | - | ||
| 491 | - #def SetDicomSeries(self, evt): | ||
| 492 | - # group = evt.data | ||
| 493 | - # self.bitmap_preview.SetDicomGroup(group) | ||
| 494 | - # self.sizer.Layout() | ||
| 495 | - # self.Update() | ||
| 496 | - | ||
| 497 | - #def ShowDicomSeries(self, pubsub_evt): | ||
| 498 | - # patient = pubsub_evt.data | ||
| 499 | - # group = patient.GetGroups()[0] | ||
| 500 | - # self.bitmap_preview.SetDicomGroup(group) | ||
| 501 | - # self.sizer.Layout() | ||
| 502 | - # self.Update() | ||
| 503 | - |
invesalius/reader/bitmap_reader.py
| @@ -139,14 +139,10 @@ class LoadBitmap: | @@ -139,14 +139,10 @@ class LoadBitmap: | ||
| 139 | global vtk_error | 139 | global vtk_error |
| 140 | 140 | ||
| 141 | #----- verify extension ------------------ | 141 | #----- verify extension ------------------ |
| 142 | - #ex = self.filepath.split('.')[-1] | ||
| 143 | - | ||
| 144 | extension = VerifyDataType(self.filepath) | 142 | extension = VerifyDataType(self.filepath) |
| 145 | 143 | ||
| 146 | file_name = self.filepath.split(os.path.sep)[-1] | 144 | file_name = self.filepath.split(os.path.sep)[-1] |
| 147 | 145 | ||
| 148 | - #if extension == 'bmp': | ||
| 149 | - # reader = vtk.vtkBMPReader() | ||
| 150 | n_array = ReadBitmap(self.filepath) | 146 | n_array = ReadBitmap(self.filepath) |
| 151 | 147 | ||
| 152 | if not(isinstance(n_array, numpy.ndarray)): | 148 | if not(isinstance(n_array, numpy.ndarray)): |
| @@ -156,9 +152,6 @@ class LoadBitmap: | @@ -156,9 +152,6 @@ class LoadBitmap: | ||
| 156 | slice_number=1, orientation="AXIAL") | 152 | slice_number=1, orientation="AXIAL") |
| 157 | 153 | ||
| 158 | 154 | ||
| 159 | - #reader.SetFileName(self.filepath) | ||
| 160 | - #reader.Update() | ||
| 161 | - | ||
| 162 | dim = image.GetDimensions() | 155 | dim = image.GetDimensions() |
| 163 | x = dim[0] | 156 | x = dim[0] |
| 164 | y = dim[1] | 157 | y = dim[1] |
| @@ -229,7 +222,6 @@ def yGetBitmaps(directory, recursive=True, gui=True): | @@ -229,7 +222,6 @@ def yGetBitmaps(directory, recursive=True, gui=True): | ||
| 229 | counter += 1 | 222 | counter += 1 |
| 230 | if gui: | 223 | if gui: |
| 231 | yield (counter,nfiles) | 224 | yield (counter,nfiles) |
| 232 | - #LoadDicom(grouper, filepath) | ||
| 233 | LoadBitmap(bmp_file, filepath) | 225 | LoadBitmap(bmp_file, filepath) |
| 234 | else: | 226 | else: |
| 235 | dirpath, dirnames, filenames = os.walk(directory) | 227 | dirpath, dirnames, filenames = os.walk(directory) |
| @@ -238,16 +230,7 @@ def yGetBitmaps(directory, recursive=True, gui=True): | @@ -238,16 +230,7 @@ def yGetBitmaps(directory, recursive=True, gui=True): | ||
| 238 | counter += 1 | 230 | counter += 1 |
| 239 | if gui: | 231 | if gui: |
| 240 | yield (counter,nfiles) | 232 | yield (counter,nfiles) |
| 241 | - #q.put(filepath) | ||
| 242 | - | ||
| 243 | - #for t in threads: | ||
| 244 | - # q.put(0) | ||
| 245 | - | ||
| 246 | - #for t in threads: | ||
| 247 | - # t.join() | ||
| 248 | 233 | ||
| 249 | - #TODO: Is this commented update necessary? | ||
| 250 | - #grouper.Update() | ||
| 251 | yield bmp_file.GetValues() | 234 | yield bmp_file.GetValues() |
| 252 | 235 | ||
| 253 | 236 | ||
| @@ -275,13 +258,6 @@ class ProgressBitmapReader: | @@ -275,13 +258,6 @@ class ProgressBitmapReader: | ||
| 275 | 258 | ||
| 276 | def GetBitmaps(self, path, recursive): | 259 | def GetBitmaps(self, path, recursive): |
| 277 | 260 | ||
| 278 | - #if not const.VTK_WARNING: | ||
| 279 | - # log_path = os.path.join(const.LOG_FOLDER, 'vtkoutput.txt') | ||
| 280 | - # fow = vtk.vtkFileOutputWindow() | ||
| 281 | - # fow.SetFileName(log_path) | ||
| 282 | - # ow = vtk.vtkOutputWindow() | ||
| 283 | - # ow.SetInstance(fow) | ||
| 284 | - | ||
| 285 | y = yGetBitmaps(path, recursive) | 261 | y = yGetBitmaps(path, recursive) |
| 286 | for value_progress in y: | 262 | for value_progress in y: |
| 287 | if not self.running: | 263 | if not self.running: |
| @@ -318,7 +294,13 @@ def ScipyRead(filepath): | @@ -318,7 +294,13 @@ def ScipyRead(filepath): | ||
| 318 | return False | 294 | return False |
| 319 | 295 | ||
| 320 | def VtkRead(filepath, t): | 296 | def VtkRead(filepath, t): |
| 321 | - | 297 | + if not const.VTK_WARNING: |
| 298 | + log_path = os.path.join(const.LOG_FOLDER, 'vtkoutput.txt') | ||
| 299 | + fow = vtk.vtkFileOutputWindow() | ||
| 300 | + fow.SetFileName(log_path) | ||
| 301 | + ow = vtk.vtkOutputWindow() | ||
| 302 | + ow.SetInstance(fow) | ||
| 303 | + | ||
| 322 | global no_error | 304 | global no_error |
| 323 | 305 | ||
| 324 | if t == "bmp": | 306 | if t == "bmp": |