Commit 33bc526299f3b69f7847fd75417eac68a72a5f50
1 parent
eb0e9272
Exists in
master
and in
39 other branches
Adpated InVesalius to run in wxpython3
Fixed problems with sizers, colors ans panel sizes. Created functions to calculate panel sizes inside foldpanelbar Showing the left-down panel where masks and surfaces info are showed applyied the patches from Olly Betts to run in wxpython3 The gradient widget is working The comboboxes from mask properties are working now. The problem was that combobox must not empty. Surface task is working again Putting combobox thresholds presets in a new line putting the import pil inside a try except expanding the label 'set predefined or manual threshold' showing the buttons when importing a dicom better layout to task_slice the size of the data_notebook the size of the buttons inside of data_notebook the size of the volume viewer icons solved the problem with position of statusbar using idle event Solved the problem with left icons Added Olly Betts as contributor Added Olly Betts as contributor Calculating best size to data notebook Removed the background colors Better sizing, but not completed. Tests data notebook with better size Better sizings Removed some unused codes Fixed the problems with backgroundcolour from statictext in the taskbar better spacings Align button "Create surface" to the right
Showing
11 changed files
with
462 additions
and
269 deletions
Show diff stats
invesalius/gui/data_notebook.py
1 | 1 | #!/usr/bin/env python |
2 | -# -*- coding: UTF-8 -*- | |
2 | +# -*- coding: UTF-8 -*- | |
3 | 3 | #-------------------------------------------------------------------------- |
4 | 4 | # Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas |
5 | 5 | # Copyright: (C) 2001 Centro de Pesquisas Renato Archer |
... | ... | @@ -22,9 +22,9 @@ import sys |
22 | 22 | import platform |
23 | 23 | |
24 | 24 | try: |
25 | - from PIL import Image | |
26 | -except(ImportError): | |
27 | 25 | import Image |
26 | +except ImportError: | |
27 | + from PIL import Image | |
28 | 28 | |
29 | 29 | import wx |
30 | 30 | import wx.grid |
... | ... | @@ -54,9 +54,8 @@ LOCATION = {const.SURFACE: _(u"3D"), |
54 | 54 | # Panel that initializes notebook and related tabs |
55 | 55 | class NotebookPanel(wx.Panel): |
56 | 56 | def __init__(self, parent): |
57 | - wx.Panel.__init__(self, parent, pos=wx.Point(0, 50), | |
58 | - size=wx.Size(256, 200)) | |
59 | - | |
57 | + wx.Panel.__init__(self, parent) | |
58 | + | |
60 | 59 | book = wx.Notebook(self, -1,style= wx.BK_DEFAULT) |
61 | 60 | # TODO: check under Windows and Linux |
62 | 61 | # this was necessary under cOS: |
... | ... | @@ -68,13 +67,13 @@ class NotebookPanel(wx.Panel): |
68 | 67 | book.AddPage(SurfacePage(book), _("3D surfaces")) |
69 | 68 | book.AddPage(MeasurePage(book), _("Measures")) |
70 | 69 | #book.AddPage(AnnotationsListCtrlPanel(book), _("Notes")) |
71 | - | |
70 | + | |
72 | 71 | book.SetSelection(0) |
73 | - | |
72 | + | |
74 | 73 | sizer = wx.BoxSizer(wx.VERTICAL) |
75 | - sizer.Add(book, 1, wx.EXPAND) | |
74 | + sizer.Add(book, 0, wx.EXPAND) | |
76 | 75 | self.SetSizer(sizer) |
77 | - | |
76 | + | |
78 | 77 | book.Refresh() |
79 | 78 | self.book = book |
80 | 79 | |
... | ... | @@ -117,8 +116,7 @@ class MeasurePage(wx.Panel): |
117 | 116 | Page related to mask items. |
118 | 117 | """ |
119 | 118 | def __init__(self, parent): |
120 | - wx.Panel.__init__(self, parent, pos=wx.Point(0, 50), | |
121 | - size=wx.Size(256, 140)) | |
119 | + wx.Panel.__init__(self, parent) | |
122 | 120 | self.__init_gui() |
123 | 121 | |
124 | 122 | def __init_gui(self): |
... | ... | @@ -148,7 +146,7 @@ class MeasureButtonControlPanel(wx.Panel): |
148 | 146 | self.__init_gui() |
149 | 147 | |
150 | 148 | def __init_gui(self): |
151 | - | |
149 | + | |
152 | 150 | # Bitmaps to be used in plate buttons |
153 | 151 | BMP_NEW = wx.Bitmap("../icons/data_new.png", |
154 | 152 | wx.BITMAP_TYPE_PNG) |
... | ... | @@ -162,16 +160,16 @@ class MeasureButtonControlPanel(wx.Panel): |
162 | 160 | button_new = pbtn.PlateButton(self, BTN_NEW, "", |
163 | 161 | BMP_NEW, |
164 | 162 | style=button_style, |
165 | - size = wx.Size(18, 18)) | |
163 | + size = wx.Size(24, 20)) | |
166 | 164 | self.button_new = button_new |
167 | 165 | button_remove = pbtn.PlateButton(self, BTN_REMOVE, "", |
168 | 166 | BMP_REMOVE, |
169 | 167 | style=button_style, |
170 | - size = wx.Size(18, 18)) | |
168 | + size = wx.Size(24, 20)) | |
171 | 169 | button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "", |
172 | 170 | BMP_DUPLICATE, |
173 | 171 | style=button_style, |
174 | - size = wx.Size(18, 18)) | |
172 | + size = wx.Size(24, 20)) | |
175 | 173 | button_duplicate.Disable() |
176 | 174 | |
177 | 175 | # Add all controls to gui |
... | ... | @@ -206,7 +204,7 @@ class MeasureButtonControlPanel(wx.Panel): |
206 | 204 | |
207 | 205 | def OnNew(self): |
208 | 206 | self.PopupMenu(self.menu) |
209 | - | |
207 | + | |
210 | 208 | def OnMenu(self, evt): |
211 | 209 | id = evt.GetId() |
212 | 210 | if id == const.MEASURE_LINEAR: |
... | ... | @@ -222,7 +220,7 @@ class MeasureButtonControlPanel(wx.Panel): |
222 | 220 | if selected_items: |
223 | 221 | Publisher.sendMessage('Duplicate measurement', selected_items) |
224 | 222 | else: |
225 | - dlg.MaskSelectionRequiredForDuplication() | |
223 | + dlg.MaskSelectionRequiredForDuplication() | |
226 | 224 | |
227 | 225 | |
228 | 226 | |
... | ... | @@ -233,8 +231,7 @@ class MaskPage(wx.Panel): |
233 | 231 | Page related to mask items. |
234 | 232 | """ |
235 | 233 | def __init__(self, parent): |
236 | - wx.Panel.__init__(self, parent, pos=wx.Point(0, 50), | |
237 | - size=wx.Size(256, 140)) | |
234 | + wx.Panel.__init__(self, parent) | |
238 | 235 | self.__init_gui() |
239 | 236 | |
240 | 237 | def __init_gui(self): |
... | ... | @@ -262,7 +259,7 @@ class ButtonControlPanel(wx.Panel): |
262 | 259 | self.__init_gui() |
263 | 260 | |
264 | 261 | def __init_gui(self): |
265 | - | |
262 | + | |
266 | 263 | # Bitmaps to be used in plate buttons |
267 | 264 | BMP_NEW = wx.Bitmap("../icons/data_new.png", |
268 | 265 | wx.BITMAP_TYPE_PNG) |
... | ... | @@ -276,15 +273,15 @@ class ButtonControlPanel(wx.Panel): |
276 | 273 | button_new = pbtn.PlateButton(self, BTN_NEW, "", |
277 | 274 | BMP_NEW, |
278 | 275 | style=button_style, |
279 | - size = wx.Size(18, 18)) | |
276 | + size = wx.Size(24, 20)) | |
280 | 277 | button_remove = pbtn.PlateButton(self, BTN_REMOVE, "", |
281 | 278 | BMP_REMOVE, |
282 | 279 | style=button_style, |
283 | - size = wx.Size(18, 18)) | |
280 | + size = wx.Size(24, 20)) | |
284 | 281 | button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "", |
285 | 282 | BMP_DUPLICATE, |
286 | 283 | style=button_style, |
287 | - size = wx.Size(18, 18)) | |
284 | + size = wx.Size(24, 20)) | |
288 | 285 | |
289 | 286 | # Add all controls to gui |
290 | 287 | sizer = wx.BoxSizer(wx.HORIZONTAL) |
... | ... | @@ -332,17 +329,17 @@ class ButtonControlPanel(wx.Panel): |
332 | 329 | if selected_items: |
333 | 330 | Publisher.sendMessage('Duplicate masks', selected_items) |
334 | 331 | else: |
335 | - dlg.MaskSelectionRequiredForDuplication() | |
332 | + dlg.MaskSelectionRequiredForDuplication() | |
336 | 333 | |
337 | 334 | class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
338 | 335 | |
339 | 336 | def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, |
340 | 337 | size=wx.DefaultSize, style=wx.LC_REPORT): |
341 | - | |
338 | + | |
342 | 339 | # native look and feel for MacOS |
343 | 340 | #if wx.Platform == "__WXMAC__": |
344 | 341 | # wx.SystemOptions.SetOptionInt("mac.listctrl.always_use_generic", 0) |
345 | - | |
342 | + | |
346 | 343 | wx.ListCtrl.__init__(self, parent, ID, pos, size, style=wx.LC_REPORT) |
347 | 344 | listmix.TextEditMixin.__init__(self) |
348 | 345 | self.mask_list_index = {} |
... | ... | @@ -351,13 +348,13 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
351 | 348 | self.__init_image_list() |
352 | 349 | self.__bind_events_wx() |
353 | 350 | self.__bind_events() |
354 | - | |
351 | + | |
355 | 352 | def __bind_events_wx(self): |
356 | 353 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) |
357 | 354 | self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEditLabel) |
358 | 355 | self.Bind(wx.EVT_KEY_UP, self.OnKeyEvent) |
359 | 356 | |
360 | - | |
357 | + | |
361 | 358 | def __bind_events(self): |
362 | 359 | Publisher.subscribe(self.AddMask, 'Add mask') |
363 | 360 | Publisher.subscribe(self.EditMaskThreshold, |
... | ... | @@ -376,7 +373,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
376 | 373 | self.RemoveMasks() |
377 | 374 | elif (keycode == wx.WXK_DELETE): |
378 | 375 | self.RemoveMasks() |
379 | - | |
376 | + | |
380 | 377 | def RemoveMasks(self): |
381 | 378 | """ |
382 | 379 | Remove selected items. |
... | ... | @@ -403,7 +400,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
403 | 400 | new_dict[i-1] = old_dict[i] |
404 | 401 | old_dict = new_dict |
405 | 402 | self.mask_list_index = new_dict |
406 | - | |
403 | + | |
407 | 404 | if new_dict: |
408 | 405 | if index == self.current_index: |
409 | 406 | self.SetItemImage(0, 1) |
... | ... | @@ -421,7 +418,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
421 | 418 | def OnCloseProject(self, pubsub_evt): |
422 | 419 | self.DeleteAllItems() |
423 | 420 | self.mask_list_index = {} |
424 | - | |
421 | + | |
425 | 422 | def OnChangeCurrentMask(self, pubsub_evt): |
426 | 423 | mask_index = pubsub_evt.data |
427 | 424 | try: |
... | ... | @@ -439,15 +436,15 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
439 | 436 | self.SetItemImage(self.current_index, 0) |
440 | 437 | |
441 | 438 | def __init_columns(self): |
442 | - | |
439 | + | |
443 | 440 | self.InsertColumn(0, "", wx.LIST_FORMAT_CENTER) |
444 | 441 | self.InsertColumn(1, _("Name")) |
445 | 442 | self.InsertColumn(2, _("Threshold"), wx.LIST_FORMAT_RIGHT) |
446 | - | |
447 | - self.SetColumnWidth(0, 20) | |
443 | + | |
444 | + self.SetColumnWidth(0, 25) | |
448 | 445 | self.SetColumnWidth(1, 120) |
449 | 446 | self.SetColumnWidth(2, 90) |
450 | - | |
447 | + | |
451 | 448 | def __init_image_list(self): |
452 | 449 | self.imagelist = wx.ImageList(16, 16) |
453 | 450 | |
... | ... | @@ -466,7 +463,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
466 | 463 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
467 | 464 | |
468 | 465 | self.image_gray = Image.open("../icons/object_colour.jpg") |
469 | - | |
466 | + | |
470 | 467 | def OnEditLabel(self, evt): |
471 | 468 | Publisher.sendMessage('Change mask name', |
472 | 469 | (evt.GetIndex(), evt.GetLabel())) |
... | ... | @@ -474,7 +471,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
474 | 471 | |
475 | 472 | def OnItemActivated(self, evt): |
476 | 473 | self.ToggleItem(evt.m_itemIndex) |
477 | - | |
474 | + | |
478 | 475 | def OnCheckItem(self, index, flag): |
479 | 476 | if flag: |
480 | 477 | for key in self.mask_list_index.keys(): |
... | ... | @@ -505,22 +502,22 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
505 | 502 | def InsertNewItem(self, index=0, label=_("Mask"), threshold="(1000, 4500)", |
506 | 503 | colour=None): |
507 | 504 | self.InsertStringItem(index, "") |
508 | - self.SetStringItem(index, 1, label, | |
509 | - imageId=self.mask_list_index[index]) | |
505 | + self.SetStringItem(index, 1, label, | |
506 | + imageId=self.mask_list_index[index]) | |
510 | 507 | self.SetStringItem(index, 2, threshold) |
511 | 508 | self.SetItemImage(index, 1) |
512 | 509 | for key in self.mask_list_index.keys(): |
513 | 510 | if key != index: |
514 | 511 | self.SetItemImage(key, 0) |
515 | 512 | self.current_index = index |
516 | - | |
513 | + | |
517 | 514 | def AddMask(self, pubsub_evt): |
518 | 515 | index, mask_name, threshold_range, colour = pubsub_evt.data |
519 | 516 | image = self.CreateColourBitmap(colour) |
520 | 517 | image_index = self.imagelist.Add(image) |
521 | 518 | self.mask_list_index[index] = image_index |
522 | 519 | self.InsertNewItem(index, mask_name, str(threshold_range)) |
523 | - | |
520 | + | |
524 | 521 | def EditMaskThreshold(self, pubsub_evt): |
525 | 522 | index, threshold_range = pubsub_evt.data |
526 | 523 | self.SetStringItem(index, 2, str(threshold_range)) |
... | ... | @@ -553,8 +550,7 @@ class SurfacePage(wx.Panel): |
553 | 550 | Page related to mask items. |
554 | 551 | """ |
555 | 552 | def __init__(self, parent): |
556 | - wx.Panel.__init__(self, parent, pos=wx.Point(0, 50), | |
557 | - size=wx.Size(256, 140)) | |
553 | + wx.Panel.__init__(self, parent) | |
558 | 554 | self.__init_gui() |
559 | 555 | |
560 | 556 | def __init_gui(self): |
... | ... | @@ -581,7 +577,7 @@ class SurfaceButtonControlPanel(wx.Panel): |
581 | 577 | self.__init_gui() |
582 | 578 | |
583 | 579 | def __init_gui(self): |
584 | - | |
580 | + | |
585 | 581 | # Bitmaps to be used in plate buttons |
586 | 582 | BMP_NEW = wx.Bitmap("../icons/data_new.png", |
587 | 583 | wx.BITMAP_TYPE_PNG) |
... | ... | @@ -595,15 +591,15 @@ class SurfaceButtonControlPanel(wx.Panel): |
595 | 591 | button_new = pbtn.PlateButton(self, BTN_NEW, "", |
596 | 592 | BMP_NEW, |
597 | 593 | style=button_style, |
598 | - size = wx.Size(18, 18)) | |
594 | + size = wx.Size(24, 20)) | |
599 | 595 | button_remove = pbtn.PlateButton(self, BTN_REMOVE, "", |
600 | 596 | BMP_REMOVE, |
601 | 597 | style=button_style, |
602 | - size = wx.Size(18, 18)) | |
598 | + size = wx.Size(24, 20)) | |
603 | 599 | button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "", |
604 | 600 | BMP_DUPLICATE, |
605 | 601 | style=button_style, |
606 | - size = wx.Size(18, 18)) | |
602 | + size = wx.Size(24, 20)) | |
607 | 603 | |
608 | 604 | # Add all controls to gui |
609 | 605 | sizer = wx.BoxSizer(wx.HORIZONTAL) |
... | ... | @@ -627,7 +623,7 @@ class SurfaceButtonControlPanel(wx.Panel): |
627 | 623 | |
628 | 624 | def OnNew(self): |
629 | 625 | sl = slice_.Slice() |
630 | - dialog = dlg.SurfaceCreationDialog(None, -1, | |
626 | + dialog = dlg.SurfaceCreationDialog(None, -1, | |
631 | 627 | _('New surface'), |
632 | 628 | mask_edited=sl.current_mask.was_edited) |
633 | 629 | try: |
... | ... | @@ -653,18 +649,18 @@ class SurfaceButtonControlPanel(wx.Panel): |
653 | 649 | if selected_items: |
654 | 650 | Publisher.sendMessage('Duplicate surfaces', selected_items) |
655 | 651 | else: |
656 | - dlg.SurfaceSelectionRequiredForDuplication() | |
652 | + dlg.SurfaceSelectionRequiredForDuplication() | |
657 | 653 | |
658 | 654 | |
659 | 655 | class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
660 | 656 | |
661 | 657 | def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, |
662 | 658 | size=wx.DefaultSize, style=wx.LC_REPORT): |
663 | - | |
659 | + | |
664 | 660 | # native look and feel for MacOS |
665 | 661 | #if wx.Platform == "__WXMAC__": |
666 | 662 | # wx.SystemOptions.SetOptionInt("mac.listctrl.always_use_generic", 0) |
667 | - | |
663 | + | |
668 | 664 | wx.ListCtrl.__init__(self, parent, ID, pos, size, style=wx.LC_REPORT) |
669 | 665 | listmix.TextEditMixin.__init__(self) |
670 | 666 | |
... | ... | @@ -686,7 +682,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
686 | 682 | Publisher.subscribe(self.OnHideSurface, 'Hide surface items') |
687 | 683 | |
688 | 684 | Publisher.subscribe(self.OnShowSingle, 'Show single surface') |
689 | - Publisher.subscribe(self.OnShowMultiple, 'Show multiple surfaces') | |
685 | + Publisher.subscribe(self.OnShowMultiple, 'Show multiple surfaces') | |
690 | 686 | |
691 | 687 | def __bind_events_wx(self): |
692 | 688 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) |
... | ... | @@ -730,7 +726,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
730 | 726 | |
731 | 727 | Publisher.sendMessage('Remove surfaces', selected_items) |
732 | 728 | else: |
733 | - dlg.SurfaceSelectionRequiredForRemoval() | |
729 | + dlg.SurfaceSelectionRequiredForRemoval() | |
734 | 730 | |
735 | 731 | def OnCloseProject(self, pubsub_evt): |
736 | 732 | self.DeleteAllItems() |
... | ... | @@ -762,17 +758,17 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
762 | 758 | return selected |
763 | 759 | |
764 | 760 | def __init_columns(self): |
765 | - | |
761 | + | |
766 | 762 | self.InsertColumn(0, "", wx.LIST_FORMAT_CENTER) |
767 | 763 | self.InsertColumn(1, _("Name")) |
768 | 764 | self.InsertColumn(2, _(u"Volume (mm³)")) |
769 | 765 | self.InsertColumn(3, _("Transparency"), wx.LIST_FORMAT_RIGHT) |
770 | - | |
771 | - self.SetColumnWidth(0, 20) | |
766 | + | |
767 | + self.SetColumnWidth(0, 25) | |
772 | 768 | self.SetColumnWidth(1, 85) |
773 | 769 | self.SetColumnWidth(2, 85) |
774 | 770 | self.SetColumnWidth(3, 80) |
775 | - | |
771 | + | |
776 | 772 | def __init_image_list(self): |
777 | 773 | self.imagelist = wx.ImageList(16, 16) |
778 | 774 | |
... | ... | @@ -787,7 +783,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
787 | 783 | bitmap.SetWidth(16) |
788 | 784 | bitmap.SetHeight(16) |
789 | 785 | img_check = self.imagelist.Add(bitmap) |
790 | - | |
786 | + | |
791 | 787 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
792 | 788 | |
793 | 789 | self.image_gray = Image.open("../icons/object_colour.jpg") |
... | ... | @@ -795,13 +791,13 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
795 | 791 | def OnEditLabel(self, evt): |
796 | 792 | Publisher.sendMessage('Change surface name', (evt.GetIndex(), evt.GetLabel())) |
797 | 793 | evt.Skip() |
798 | - | |
794 | + | |
799 | 795 | def OnItemActivated(self, evt): |
800 | 796 | self.ToggleItem(evt.m_itemIndex) |
801 | 797 | evt.Skip() |
802 | - | |
798 | + | |
803 | 799 | def OnCheckItem(self, index, flag): |
804 | - Publisher.sendMessage('Show surface', (index, flag)) | |
800 | + Publisher.sendMessage('Show surface', (index, flag)) | |
805 | 801 | |
806 | 802 | def OnShowSingle(self, pubsub_evt): |
807 | 803 | index, visibility = pubsub_evt.data |
... | ... | @@ -809,7 +805,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
809 | 805 | if key != index: |
810 | 806 | self.SetItemImage(key, not visibility) |
811 | 807 | Publisher.sendMessage('Show surface', |
812 | - (key, not visibility)) | |
808 | + (key, not visibility)) | |
813 | 809 | self.SetItemImage(index, visibility) |
814 | 810 | Publisher.sendMessage('Show surface', |
815 | 811 | (index, visibility)) |
... | ... | @@ -820,7 +816,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
820 | 816 | if key not in index_list: |
821 | 817 | self.SetItemImage(key, not visibility) |
822 | 818 | Publisher.sendMessage('Show surface', |
823 | - (key, not visibility)) | |
819 | + (key, not visibility)) | |
824 | 820 | for index in index_list: |
825 | 821 | self.SetItemImage(index, visibility) |
826 | 822 | Publisher.sendMessage('Show surface', |
... | ... | @@ -832,7 +828,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
832 | 828 | colour = pubsub_evt.data[2] |
833 | 829 | volume = "%.3f"%pubsub_evt.data[3] |
834 | 830 | transparency = "%d%%"%(int(100*pubsub_evt.data[4])) |
835 | - | |
831 | + | |
836 | 832 | if index not in self.surface_list_index: |
837 | 833 | image = self.CreateColourBitmap(colour) |
838 | 834 | image_index = self.imagelist.Add(image) |
... | ... | @@ -849,7 +845,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
849 | 845 | transparency="0%%", colour=None): |
850 | 846 | self.InsertStringItem(index, "") |
851 | 847 | self.SetStringItem(index, 1, label, |
852 | - imageId = self.surface_list_index[index]) | |
848 | + imageId = self.surface_list_index[index]) | |
853 | 849 | self.SetStringItem(index, 2, volume) |
854 | 850 | self.SetStringItem(index, 3, transparency) |
855 | 851 | self.SetItemImage(index, 1) |
... | ... | @@ -857,11 +853,11 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
857 | 853 | def UpdateItemInfo(self, index=0, label="Surface 1", volume="0 mm3", |
858 | 854 | transparency="0%%", colour=None): |
859 | 855 | self.SetStringItem(index, 1, label, |
860 | - imageId = self.surface_list_index[index]) | |
856 | + imageId = self.surface_list_index[index]) | |
861 | 857 | self.SetStringItem(index, 2, volume) |
862 | 858 | self.SetStringItem(index, 3, transparency) |
863 | 859 | self.SetItemImage(index, 1) |
864 | - | |
860 | + | |
865 | 861 | def CreateColourBitmap(self, colour): |
866 | 862 | """ |
867 | 863 | Create a wx Image with a mask colour. |
... | ... | @@ -887,7 +883,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
887 | 883 | """ |
888 | 884 | index, value = pubsub_evt.data |
889 | 885 | self.SetStringItem(index, 3, "%d%%"%(int(value*100))) |
890 | - | |
886 | + | |
891 | 887 | def EditSurfaceColour(self, pubsub_evt): |
892 | 888 | """ |
893 | 889 | """ |
... | ... | @@ -905,11 +901,11 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
905 | 901 | |
906 | 902 | def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, |
907 | 903 | size=wx.DefaultSize, style=wx.LC_REPORT): |
908 | - | |
904 | + | |
909 | 905 | # native look and feel for MacOS |
910 | 906 | #if wx.Platform == "__WXMAC__": |
911 | 907 | # wx.SystemOptions.SetOptionInt("mac.listctrl.always_use_generic", 0) |
912 | - | |
908 | + | |
913 | 909 | wx.ListCtrl.__init__(self, parent, ID, pos, size, style=wx.LC_REPORT) |
914 | 910 | listmix.TextEditMixin.__init__(self) |
915 | 911 | |
... | ... | @@ -927,7 +923,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
927 | 923 | 'Set measurement colour') |
928 | 924 | Publisher.subscribe(self.OnCloseProject, 'Close project data') |
929 | 925 | Publisher.subscribe(self.OnShowSingle, 'Show single measurement') |
930 | - Publisher.subscribe(self.OnShowMultiple, 'Show multiple measurements') | |
926 | + Publisher.subscribe(self.OnShowMultiple, 'Show multiple measurements') | |
931 | 927 | Publisher.subscribe(self.OnLoadData, 'Load measurement dict') |
932 | 928 | |
933 | 929 | def __bind_events_wx(self): |
... | ... | @@ -1007,13 +1003,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1007 | 1003 | self.InsertColumn(2, _("Location")) |
1008 | 1004 | self.InsertColumn(3, _("Type")) |
1009 | 1005 | self.InsertColumn(4, _("Value"), wx.LIST_FORMAT_RIGHT) |
1010 | - | |
1011 | - self.SetColumnWidth(0, 20) | |
1006 | + | |
1007 | + self.SetColumnWidth(0, 25) | |
1012 | 1008 | self.SetColumnWidth(1, 65) |
1013 | 1009 | self.SetColumnWidth(2, 55) |
1014 | 1010 | self.SetColumnWidth(3, 50) |
1015 | 1011 | self.SetColumnWidth(4, 75) |
1016 | - | |
1012 | + | |
1017 | 1013 | def __init_image_list(self): |
1018 | 1014 | self.imagelist = wx.ImageList(16, 16) |
1019 | 1015 | |
... | ... | @@ -1028,7 +1024,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1028 | 1024 | bitmap.SetWidth(16) |
1029 | 1025 | bitmap.SetHeight(16) |
1030 | 1026 | img_check = self.imagelist.Add(bitmap) |
1031 | - | |
1027 | + | |
1032 | 1028 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
1033 | 1029 | |
1034 | 1030 | self.image_gray = Image.open("../icons/object_colour.jpg") |
... | ... | @@ -1037,14 +1033,14 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1037 | 1033 | def OnEditLabel(self, evt): |
1038 | 1034 | Publisher.sendMessage('Change measurement name', (evt.GetIndex(), evt.GetLabel())) |
1039 | 1035 | evt.Skip() |
1040 | - | |
1036 | + | |
1041 | 1037 | def OnItemActivated(self, evt): |
1042 | 1038 | self.ToggleItem(evt.m_itemIndex) |
1043 | 1039 | evt.Skip() |
1044 | 1040 | |
1045 | - | |
1041 | + | |
1046 | 1042 | def OnCheckItem(self, index, flag): |
1047 | - Publisher.sendMessage('Show measurement', (index, flag)) | |
1043 | + Publisher.sendMessage('Show measurement', (index, flag)) | |
1048 | 1044 | |
1049 | 1045 | def OnShowSingle(self, pubsub_evt): |
1050 | 1046 | index, visibility = pubsub_evt.data |
... | ... | @@ -1052,7 +1048,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1052 | 1048 | if key != index: |
1053 | 1049 | self.SetItemImage(key, not visibility) |
1054 | 1050 | Publisher.sendMessage('Show measurement', |
1055 | - (key, not visibility)) | |
1051 | + (key, not visibility)) | |
1056 | 1052 | self.SetItemImage(index, visibility) |
1057 | 1053 | Publisher.sendMessage('Show measurement', |
1058 | 1054 | (index, visibility)) |
... | ... | @@ -1063,7 +1059,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1063 | 1059 | if key not in index_list: |
1064 | 1060 | self.SetItemImage(key, not visibility) |
1065 | 1061 | Publisher.sendMessage('Show measurement', |
1066 | - (key, not visibility)) | |
1062 | + (key, not visibility)) | |
1067 | 1063 | for index in index_list: |
1068 | 1064 | self.SetItemImage(index, visibility) |
1069 | 1065 | Publisher.sendMessage('Show measurement', |
... | ... | @@ -1078,7 +1074,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1078 | 1074 | m = items_dict[i] |
1079 | 1075 | image = self.CreateColourBitmap(m.colour) |
1080 | 1076 | image_index = self.imagelist.Add(image) |
1081 | - | |
1077 | + | |
1082 | 1078 | index_list = self._list_index.keys() |
1083 | 1079 | self._list_index[m.index] = image_index |
1084 | 1080 | |
... | ... | @@ -1105,7 +1101,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1105 | 1101 | if index not in self._list_index: |
1106 | 1102 | image = self.CreateColourBitmap(colour) |
1107 | 1103 | image_index = self.imagelist.Add(image) |
1108 | - | |
1104 | + | |
1109 | 1105 | index_list = self._list_index.keys() |
1110 | 1106 | self._list_index[index] = image_index |
1111 | 1107 | |
... | ... | @@ -1120,7 +1116,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1120 | 1116 | location="SURFACE", type_="LINEAR", value="0 mm"): |
1121 | 1117 | self.InsertStringItem(index, "") |
1122 | 1118 | self.SetStringItem(index, 1, label, |
1123 | - imageId = self._list_index[index]) | |
1119 | + imageId = self._list_index[index]) | |
1124 | 1120 | self.SetStringItem(index, 2, location) |
1125 | 1121 | self.SetStringItem(index, 3, type_) |
1126 | 1122 | self.SetStringItem(index, 4, value) |
... | ... | @@ -1130,13 +1126,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1130 | 1126 | def UpdateItemInfo(self, index=0, label="Measurement 1", colour=None, |
1131 | 1127 | type_="LINEAR", location="SURFACE", value="0 mm"): |
1132 | 1128 | self.SetStringItem(index, 1, label, |
1133 | - imageId = self._list_index[index]) | |
1129 | + imageId = self._list_index[index]) | |
1134 | 1130 | self.SetStringItem(index, 2, type_) |
1135 | 1131 | self.SetStringItem(index, 3, location) |
1136 | 1132 | self.SetStringItem(index, 4, value) |
1137 | 1133 | self.SetItemImage(index, 1) |
1138 | 1134 | self.Refresh() |
1139 | - | |
1135 | + | |
1140 | 1136 | def CreateColourBitmap(self, colour): |
1141 | 1137 | """ |
1142 | 1138 | Create a wx Image with a mask colour. |
... | ... | @@ -1169,41 +1165,41 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1169 | 1165 | #******************************************************************* |
1170 | 1166 | #******************************************************************* |
1171 | 1167 | |
1172 | - | |
1168 | + | |
1173 | 1169 | class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1174 | 1170 | # TODO: Remove edimixin, allow only visible and invisible |
1175 | 1171 | def __init__(self, parent, ID=-1, pos=wx.DefaultPosition, |
1176 | 1172 | size=wx.DefaultSize, style=wx.LC_REPORT): |
1177 | - | |
1173 | + | |
1178 | 1174 | # native look and feel for MacOS |
1179 | 1175 | #if wx.Platform == "__WXMAC__": |
1180 | 1176 | # wx.SystemOptions.SetOptionInt("mac.listctrl.always_use_generic", 0) |
1181 | - | |
1177 | + | |
1182 | 1178 | wx.ListCtrl.__init__(self, parent, ID, pos, size, style=wx.LC_REPORT) |
1183 | 1179 | listmix.TextEditMixin.__init__(self) |
1184 | 1180 | |
1185 | 1181 | self.__init_columns() |
1186 | 1182 | self.__init_image_list() |
1187 | 1183 | self.__init_evt() |
1188 | - | |
1184 | + | |
1189 | 1185 | # just testing |
1190 | 1186 | self.Populate() |
1191 | - | |
1187 | + | |
1192 | 1188 | def __init_evt(self): |
1193 | 1189 | self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) |
1194 | 1190 | |
1195 | 1191 | def __init_columns(self): |
1196 | - | |
1192 | + | |
1197 | 1193 | self.InsertColumn(0, "", wx.LIST_FORMAT_CENTER) |
1198 | 1194 | self.InsertColumn(1, _("Name")) |
1199 | 1195 | self.InsertColumn(2, _("Type"), wx.LIST_FORMAT_CENTER) |
1200 | 1196 | self.InsertColumn(3, _("Value")) |
1201 | - | |
1202 | - self.SetColumnWidth(0, 20) | |
1197 | + | |
1198 | + self.SetColumnWidth(0, 25) | |
1203 | 1199 | self.SetColumnWidth(1, 90) |
1204 | 1200 | self.SetColumnWidth(2, 50) |
1205 | 1201 | self.SetColumnWidth(3, 120) |
1206 | - | |
1202 | + | |
1207 | 1203 | def __init_image_list(self): |
1208 | 1204 | self.imagelist = wx.ImageList(16, 16) |
1209 | 1205 | |
... | ... | @@ -1212,7 +1208,7 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1212 | 1208 | bitmap.SetWidth(16) |
1213 | 1209 | bitmap.SetHeight(16) |
1214 | 1210 | img_check = self.imagelist.Add(bitmap) |
1215 | - | |
1211 | + | |
1216 | 1212 | image = wx.Image("../icons/object_invisible.jpg") |
1217 | 1213 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
1218 | 1214 | bitmap.SetWidth(16) |
... | ... | @@ -1224,13 +1220,13 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1224 | 1220 | bitmap.SetWidth(16) |
1225 | 1221 | bitmap.SetHeight(16) |
1226 | 1222 | self.img_colour = self.imagelist.Add(bitmap) |
1227 | - | |
1223 | + | |
1228 | 1224 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
1229 | 1225 | |
1230 | - | |
1226 | + | |
1231 | 1227 | def OnItemActivated(self, evt): |
1232 | 1228 | self.ToggleItem(evt.m_itemIndex) |
1233 | - | |
1229 | + | |
1234 | 1230 | def OnCheckItem(self, index, flag): |
1235 | 1231 | # TODO: use pubsub to communicate to models |
1236 | 1232 | if flag: |
... | ... | @@ -1241,10 +1237,10 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
1241 | 1237 | def InsertNewItem(self, index=0, name="Axial 1", type_="2d", |
1242 | 1238 | value="bla", colour=None): |
1243 | 1239 | self.InsertStringItem(index, "") |
1244 | - self.SetStringItem(index, 1, name, imageId = self.img_colour) | |
1240 | + self.SetStringItem(index, 1, name, imageId = self.img_colour) | |
1245 | 1241 | self.SetStringItem(index, 2, type_) |
1246 | 1242 | self.SetStringItem(index, 3, value) |
1247 | - | |
1243 | + | |
1248 | 1244 | def Populate(self): |
1249 | 1245 | dict = ((0, "Axial 1", "2D", "blalbalblabllablalbla"), |
1250 | 1246 | (1, "Coronal 1", "2D", "hello here we are again"), | ... | ... |
invesalius/gui/default_tasks.py
... | ... | @@ -100,32 +100,47 @@ class Panel(wx.Panel): |
100 | 100 | wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), |
101 | 101 | size=wx.Size(280, 656)) |
102 | 102 | |
103 | - sizer = wx.BoxSizer(wx.VERTICAL) | |
103 | + #sizer = wx.BoxSizer(wx.VERTICAL) | |
104 | + gbs = wx.GridBagSizer(5,5) | |
104 | 105 | #sizer.Add(UpperTaskPanel(self), 5, wx.EXPAND|wx.GROW) |
105 | - sizer.Add(UpperTaskPanel(self), 16, wx.EXPAND|wx.GROW) | |
106 | + gbs.Add(UpperTaskPanel(self), (0, 0), flag=wx.EXPAND) | |
106 | 107 | |
107 | 108 | #sizer.Add(LowerTaskPanel(self), 3, wx.EXPAND|wx.GROW) |
108 | - sizer.Add(LowerTaskPanel(self), 6, wx.EXPAND|wx.GROW) | |
109 | + gbs.Add(LowerTaskPanel(self), (1, 0), flag=wx.EXPAND | wx.ALIGN_BOTTOM) | |
110 | + | |
111 | + gbs.AddGrowableCol(0) | |
109 | 112 | |
113 | + gbs.AddGrowableRow(0, 1) | |
114 | + gbs.AddGrowableRow(1, 0) | |
115 | + | |
116 | + sizer = wx.BoxSizer(wx.VERTICAL) | |
117 | + sizer.Add(gbs, 1, wx.EXPAND) | |
110 | 118 | |
119 | + self.gbs = gbs | |
120 | + | |
121 | + #self.SetSizerAndFit(sizer) | |
111 | 122 | self.SetSizer(sizer) |
112 | 123 | |
124 | + | |
113 | 125 | # Lower fold panel |
114 | 126 | class LowerTaskPanel(wx.Panel): |
115 | 127 | def __init__(self, parent): |
116 | - wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), | |
117 | - # size=wx.Size(280, 700)) | |
118 | - size=wx.Size(280, 420)) | |
128 | + wx.Panel.__init__(self, parent, size=(150, -1)) | |
129 | + fold_panel = fpb.FoldPanelBar(self, -1, | |
130 | + style=FPB_DEFAULT_STYLE, | |
131 | + agwStyle=fpb.FPB_COLLAPSE_TO_BOTTOM) | |
119 | 132 | |
120 | - fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, | |
121 | - self.GetSize(),FPB_DEFAULT_STYLE, | |
122 | - fpb.FPB_COLLAPSE_TO_BOTTOM) | |
133 | + self.fold_panel = fold_panel | |
123 | 134 | |
124 | 135 | self.enable_items = [] |
125 | 136 | self.overwrite = False |
126 | 137 | |
138 | + gbs = wx.GridBagSizer(5,5) | |
139 | + gbs.AddGrowableCol(0, 1) | |
140 | + self.gbs = gbs | |
141 | + | |
127 | 142 | sizer = wx.BoxSizer(wx.VERTICAL) |
128 | - sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) | |
143 | + sizer.Add(gbs, 1, wx.GROW|wx.EXPAND) | |
129 | 144 | self.SetSizer(sizer) |
130 | 145 | |
131 | 146 | image_list = wx.ImageList(16,16) |
... | ... | @@ -139,27 +154,50 @@ class LowerTaskPanel(wx.Panel): |
139 | 154 | col = style.GetFirstColour() |
140 | 155 | self.enable_items.append(item) |
141 | 156 | |
142 | - fold_panel.AddFoldPanelWindow(item, nb.NotebookPanel(item), #Spacing= 0, | |
157 | + #npanel = wx.Panel(self, -1) | |
158 | + self.npanel = nb.NotebookPanel(item) | |
159 | + | |
160 | + self.__calc_best_size(self.npanel) | |
161 | + | |
162 | + fold_panel.AddFoldPanelWindow(item, self.npanel, #fpb.FPB_ALIGN_WIDTH, #Spacing= 0, | |
143 | 163 | leftSpacing=0, rightSpacing=0) |
144 | - fold_panel.Expand(fold_panel.GetFoldPanel(0)) | |
145 | 164 | |
146 | - # Fold 2 - Tools | |
147 | - # Measures | |
148 | - # Text Annotations | |
149 | - #item = fold_panel.AddFoldPanel(_("Tools"), collapsed=False, | |
150 | - # foldIcons=image_list) | |
151 | - #style = fold_panel.GetCaptionStyle(item) | |
152 | - #col = style.GetFirstColour() | |
153 | - #elf.enable_items.append(item) | |
154 | - # | |
155 | - #fold_panel.AddFoldPanelWindow(item, tools.TaskPanel(item), Spacing= 0, | |
156 | - # leftSpacing=0, rightSpacing=0) | |
157 | - #fold_panel.Expand(fold_panel.GetFoldPanel(1)) | |
165 | + gbs.AddGrowableRow(0, 1) | |
166 | + gbs.Add(fold_panel, (0, 0), flag=wx.EXPAND) | |
167 | + gbs.Layout() | |
168 | + item.ResizePanel() | |
169 | + | |
170 | + sizer.Fit(self) | |
171 | + self.Fit() | |
158 | 172 | |
159 | 173 | self.SetStateProjectClose() |
160 | 174 | self.__bind_events() |
161 | 175 | |
162 | 176 | |
177 | + def __calc_best_size(self, panel): | |
178 | + parent = panel.GetParent() | |
179 | + panel.Reparent(self) | |
180 | + | |
181 | + gbs = self.gbs | |
182 | + fold_panel = self.fold_panel | |
183 | + | |
184 | + # Calculating the size | |
185 | + gbs.AddGrowableRow(1, 1) | |
186 | + #gbs.AddGrowableRow(0, 1) | |
187 | + gbs.Add(fold_panel, (0, 0), flag=wx.EXPAND) | |
188 | + gbs.Add(panel, (1, 0), flag=wx.EXPAND) | |
189 | + gbs.Layout() | |
190 | + self.Fit() | |
191 | + size = panel.GetSize() | |
192 | + | |
193 | + gbs.Remove(1) | |
194 | + gbs.Remove(0) | |
195 | + gbs.RemoveGrowableRow(1) | |
196 | + | |
197 | + panel.Reparent(parent) | |
198 | + panel.SetInitialSize(size) | |
199 | + self.SetInitialSize(self.GetSize()) | |
200 | + | |
163 | 201 | def __bind_events(self): |
164 | 202 | Publisher.subscribe(self.OnEnableState, "Enable state project") |
165 | 203 | |
... | ... | @@ -178,20 +216,20 @@ class LowerTaskPanel(wx.Panel): |
178 | 216 | for item in self.enable_items: |
179 | 217 | item.Enable() |
180 | 218 | |
219 | + def ResizeFPB(self): | |
220 | + sizeNeeded = self.fold_panel.GetPanelsLength(0, 0)[2] | |
221 | + self.fold_panel.SetMinSize((self.fold_panel.GetSize()[0], sizeNeeded )) | |
222 | + self.fold_panel.SetSize((self.fold_panel.GetSize()[0], sizeNeeded)) | |
223 | + | |
181 | 224 | |
182 | 225 | # Upper fold panel |
183 | 226 | class UpperTaskPanel(wx.Panel): |
184 | 227 | def __init__(self, parent): |
185 | - wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), | |
186 | - size=wx.Size(280, 656)) | |
187 | - | |
228 | + wx.Panel.__init__(self, parent) | |
188 | 229 | fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, |
189 | - self.GetSize(),FPB_DEFAULT_STYLE, | |
230 | + wx.DefaultSize,FPB_DEFAULT_STYLE, | |
190 | 231 | fpb.FPB_SINGLE_FOLD) |
191 | 232 | |
192 | - #self.SetBackgroundColour((0,255,0)) | |
193 | - | |
194 | - | |
195 | 233 | sizer = wx.BoxSizer(wx.VERTICAL) |
196 | 234 | sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) |
197 | 235 | self.SetSizer(sizer) |
... | ... | @@ -210,7 +248,8 @@ class UpperTaskPanel(wx.Panel): |
210 | 248 | tasks = [(_("Load data"), importer.TaskPanel), |
211 | 249 | (_("Select region of interest"), slice_.TaskPanel), |
212 | 250 | (_("Configure 3D surface"), surface.TaskPanel), |
213 | - (_("Export data"), exporter.TaskPanel)] | |
251 | + (_("Export data"), exporter.TaskPanel) | |
252 | + ] | |
214 | 253 | elif int(session.mode) == const.MODE_NAVIGATOR: |
215 | 254 | tasks = [(_("Load data"), importer.TaskPanel), |
216 | 255 | (_("Select region of interest"), slice_.TaskPanel), |
... | ... | @@ -300,3 +339,9 @@ class UpperTaskPanel(wx.Panel): |
300 | 339 | |
301 | 340 | |
302 | 341 | evt.Skip() |
342 | + wx.CallAfter(self.ResizeFPB) | |
343 | + | |
344 | + def ResizeFPB(self): | |
345 | + sizeNeeded = self.fold_panel.GetPanelsLength(0, 0)[2] | |
346 | + self.fold_panel.SetMinSize((self.fold_panel.GetSize()[0], sizeNeeded )) | |
347 | + self.fold_panel.SetSize((self.fold_panel.GetSize()[0], sizeNeeded)) | ... | ... |
invesalius/gui/default_viewers.py
... | ... | @@ -330,7 +330,7 @@ class VolumeViewerCover(wx.Panel): |
330 | 330 | |
331 | 331 | class VolumeToolPanel(wx.Panel): |
332 | 332 | def __init__(self, parent): |
333 | - wx.Panel.__init__(self, parent, size = (10,100)) | |
333 | + wx.Panel.__init__(self, parent) | |
334 | 334 | |
335 | 335 | # VOLUME RAYCASTING BUTTON |
336 | 336 | BMP_RAYCASTING = wx.Bitmap("../icons/volume_raycasting.png", |
... | ... | @@ -346,15 +346,15 @@ class VolumeToolPanel(wx.Panel): |
346 | 346 | |
347 | 347 | button_raycasting = pbtn.PlateButton(self, BUTTON_RAYCASTING,"", |
348 | 348 | BMP_RAYCASTING, style=pbtn.PB_STYLE_SQUARE, |
349 | - size=(24,24)) | |
349 | + size=(32,32)) | |
350 | 350 | |
351 | 351 | button_stereo = pbtn.PlateButton(self, BUTTON_3D_STEREO,"", |
352 | 352 | BMP_3D_STEREO, style=pbtn.PB_STYLE_SQUARE, |
353 | - size=(24,24)) | |
353 | + size=(32,32)) | |
354 | 354 | |
355 | 355 | button_slice_plane = self.button_slice_plane = pbtn.PlateButton(self, BUTTON_SLICE_PLANE,"", |
356 | 356 | BMP_SLICE_PLANE, style=pbtn.PB_STYLE_SQUARE, |
357 | - size=(24,24)) | |
357 | + size=(32,32)) | |
358 | 358 | |
359 | 359 | self.button_raycasting = button_raycasting |
360 | 360 | self.button_stereo = button_stereo |
... | ... | @@ -363,13 +363,13 @@ class VolumeToolPanel(wx.Panel): |
363 | 363 | BMP_FRONT = wx.Bitmap(ID_TO_BMP[const.VOL_FRONT][1], |
364 | 364 | wx.BITMAP_TYPE_PNG) |
365 | 365 | button_view = pbtn.PlateButton(self, BUTTON_VIEW, "", |
366 | - BMP_FRONT, size=(24,24), | |
366 | + BMP_FRONT, size=(32,32), | |
367 | 367 | style=pbtn.PB_STYLE_SQUARE) |
368 | 368 | self.button_view = button_view |
369 | 369 | |
370 | 370 | # VOLUME COLOUR BUTTON |
371 | 371 | if sys.platform == 'linux2': |
372 | - size = (28,28) | |
372 | + size = (32,32) | |
373 | 373 | sp = 2 |
374 | 374 | else: |
375 | 375 | size = (24,24) | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -215,7 +215,7 @@ def ShowOpenProjectDialog(): |
215 | 215 | dlg = wx.FileDialog(None, message=_("Open InVesalius 3 project..."), |
216 | 216 | defaultDir="", |
217 | 217 | defaultFile="", wildcard=WILDCARD_OPEN, |
218 | - style=wx.OPEN|wx.CHANGE_DIR) | |
218 | + style=wx.FD_OPEN|wx.FD_CHANGE_DIR) | |
219 | 219 | |
220 | 220 | # inv3 filter is default |
221 | 221 | dlg.SetFilterIndex(0) |
... | ... | @@ -243,7 +243,7 @@ def ShowOpenAnalyzeDialog(): |
243 | 243 | dlg = wx.FileDialog(None, message=_("Open Analyze file"), |
244 | 244 | defaultDir="", |
245 | 245 | defaultFile="", wildcard=WILDCARD_ANALYZE, |
246 | - style=wx.OPEN|wx.CHANGE_DIR) | |
246 | + style=wx.FD_OPEN|wx.FD_CHANGE_DIR) | |
247 | 247 | |
248 | 248 | # inv3 filter is default |
249 | 249 | dlg.SetFilterIndex(0) |
... | ... | @@ -313,7 +313,7 @@ def ShowSaveAsProjectDialog(default_filename=None): |
313 | 313 | "", # last used directory |
314 | 314 | default_filename, |
315 | 315 | _("InVesalius project (*.inv3)|*.inv3"), |
316 | - wx.SAVE|wx.OVERWRITE_PROMPT) | |
316 | + wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) | |
317 | 317 | #dlg.SetFilterIndex(0) # default is VTI |
318 | 318 | |
319 | 319 | filename = None |
... | ... | @@ -780,7 +780,8 @@ def ShowAboutDialog(parent): |
780 | 780 | "Tatiana Al-Chueyr (former)", |
781 | 781 | "Guilherme Cesar Soares Ruppert (former)", |
782 | 782 | "Fabio de Souza Azevedo (former)", |
783 | - "Bruno Lara Bottazzini (contributor)"] | |
783 | + "Bruno Lara Bottazzini (contributor)", | |
784 | + "Olly Betts (patches to support wxPython3)"] | |
784 | 785 | |
785 | 786 | info.Translators = ["Alex P. Natsios", |
786 | 787 | "Andreas Loupasakis", |
... | ... | @@ -973,7 +974,7 @@ def ExportPicture(type_=""): |
973 | 974 | "", # last used directory |
974 | 975 | project_name, # filename |
975 | 976 | WILDCARD_SAVE_PICTURE, |
976 | - wx.SAVE|wx.OVERWRITE_PROMPT) | |
977 | + wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) | |
977 | 978 | dlg.SetFilterIndex(1) # default is VTI |
978 | 979 | |
979 | 980 | if dlg.ShowModal() == wx.ID_OK: | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -85,6 +85,7 @@ class Frame(wx.Frame): |
85 | 85 | if sys.platform != 'darwin': |
86 | 86 | self.Maximize() |
87 | 87 | |
88 | + self.sizeChanged = True | |
88 | 89 | #Necessary update AUI (statusBar in special) |
89 | 90 | #when maximized in the Win 7 and XP |
90 | 91 | self.SetSize(self.GetSize()) |
... | ... | @@ -132,6 +133,7 @@ class Frame(wx.Frame): |
132 | 133 | Bind normal events from wx (except pubsub related). |
133 | 134 | """ |
134 | 135 | self.Bind(wx.EVT_SIZE, self.OnSize) |
136 | + self.Bind(wx.EVT_IDLE, self.OnIdle) | |
135 | 137 | self.Bind(wx.EVT_MENU, self.OnMenuClick) |
136 | 138 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
137 | 139 | #self.Bind(wx.EVT_MOVE, self.OnMove) |
... | ... | @@ -404,8 +406,17 @@ class Frame(wx.Frame): |
404 | 406 | """ |
405 | 407 | Refresh GUI when frame is resized. |
406 | 408 | """ |
407 | - Publisher.sendMessage(('ProgressBar Reposition')) | |
408 | 409 | evt.Skip() |
410 | + self.Reposition() | |
411 | + self.sizeChanged = True | |
412 | + | |
413 | + def OnIdle(self, evt): | |
414 | + if self.sizeChanged: | |
415 | + self.Reposition() | |
416 | + | |
417 | + def Reposition(self): | |
418 | + Publisher.sendMessage(('ProgressBar Reposition')) | |
419 | + self.sizeChanged = False | |
409 | 420 | |
410 | 421 | |
411 | 422 | def OnMove(self, evt): |
... | ... | @@ -596,13 +607,13 @@ class MenuBar(wx.MenuBar): |
596 | 607 | |
597 | 608 | file_edit_item_undo = wx.MenuItem(file_edit, wx.ID_UNDO, _("Undo\tCtrl+Z")) |
598 | 609 | file_edit_item_undo.SetBitmap(self.BMP_UNDO) |
599 | - file_edit_item_undo.Enable(False) | |
600 | 610 | file_edit.AppendItem(file_edit_item_undo) |
611 | + file_edit_item_undo.Enable(False) | |
601 | 612 | |
602 | 613 | file_edit_item_redo = wx.MenuItem(file_edit, wx.ID_REDO, _("Redo\tCtrl+Y")) |
603 | 614 | file_edit_item_redo.SetBitmap(self.BMP_REDO) |
604 | - file_edit_item_redo.Enable(False) | |
605 | 615 | file_edit.AppendItem(file_edit_item_redo) |
616 | + file_edit_item_redo.Enable(False) | |
606 | 617 | else: |
607 | 618 | file_edit.Append(wx.ID_UNDO, _("Undo\tCtrl+Z")).Enable(False) |
608 | 619 | file_edit.Append(wx.ID_REDO, _("Redo\tCtrl+Y")).Enable(False) |
... | ... | @@ -732,9 +743,10 @@ class ProgressBar(wx.Gauge): |
732 | 743 | """ |
733 | 744 | Compute new size and position, according to parent resize |
734 | 745 | """ |
735 | - rect = self.parent.GetFieldRect(2) | |
746 | + rect = self.Parent.GetFieldRect(2) | |
736 | 747 | self.SetPosition((rect.x + 2, rect.y + 2)) |
737 | 748 | self.SetSize((rect.width - 4, rect.height - 4)) |
749 | + self.Show() | |
738 | 750 | |
739 | 751 | def SetPercentage(self, value): |
740 | 752 | """ | ... | ... |
invesalius/gui/import_panel.py
... | ... | @@ -110,16 +110,16 @@ class InnerPanel(wx.Panel): |
110 | 110 | |
111 | 111 | sizer = wx.BoxSizer(wx.VERTICAL) |
112 | 112 | sizer.Add(splitter, 20, wx.EXPAND) |
113 | - sizer.Add(panel, 1, wx.EXPAND|wx.LEFT, 90) | |
114 | - | |
115 | - self.SetSizer(sizer) | |
116 | - sizer.Fit(self) | |
113 | + sizer.Add(panel, 0, wx.EXPAND|wx.LEFT, 90) | |
117 | 114 | |
118 | 115 | self.text_panel = TextPanel(splitter) |
119 | 116 | splitter.AppendWindow(self.text_panel, 250) |
120 | 117 | |
121 | 118 | self.image_panel = ImagePanel(splitter) |
122 | 119 | splitter.AppendWindow(self.image_panel, 250) |
120 | + | |
121 | + self.SetSizer(sizer) | |
122 | + sizer.Fit(self) | |
123 | 123 | |
124 | 124 | self.Layout() |
125 | 125 | self.Update() | ... | ... |
invesalius/gui/task_exporter.py
... | ... | @@ -44,7 +44,7 @@ WILDCARD_SAVE_3D = "Inventor (*.iv)|*.iv|"\ |
44 | 44 | "VTK PolyData (*.vtp)|*.vtp|"\ |
45 | 45 | "Wavefront (*.obj)|*.obj|"\ |
46 | 46 | "X3D (*.x3d)|*.x3d" |
47 | - | |
47 | + | |
48 | 48 | INDEX_TO_TYPE_3D = {0: const.FILETYPE_IV, |
49 | 49 | 1: const.FILETYPE_PLY, |
50 | 50 | 2: const.FILETYPE_RIB, |
... | ... | @@ -86,7 +86,7 @@ class TaskPanel(wx.Panel): |
86 | 86 | |
87 | 87 | inner_panel = InnerTaskPanel(self) |
88 | 88 | |
89 | - sizer = wx.BoxSizer(wx.HORIZONTAL) | |
89 | + sizer = wx.BoxSizer(wx.VERTICAL) | |
90 | 90 | sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT | |
91 | 91 | wx.LEFT, 7) |
92 | 92 | sizer.Fit(self) |
... | ... | @@ -99,7 +99,8 @@ class InnerTaskPanel(wx.Panel): |
99 | 99 | |
100 | 100 | def __init__(self, parent): |
101 | 101 | wx.Panel.__init__(self, parent) |
102 | - self.SetBackgroundColour(wx.Colour(255,255,255)) | |
102 | + backgroud_colour = wx.Colour(255,255,255) | |
103 | + self.SetBackgroundColour(backgroud_colour) | |
103 | 104 | self.SetAutoLayout(1) |
104 | 105 | |
105 | 106 | # Counter for projects loaded in current GUI |
... | ... | @@ -109,7 +110,9 @@ class InnerTaskPanel(wx.Panel): |
109 | 110 | link_export_picture = hl.HyperLinkCtrl(self, -1, |
110 | 111 | _("Export picture...")) |
111 | 112 | link_export_picture.SetUnderlines(False, False, False) |
113 | + link_export_picture.SetBold(True) | |
112 | 114 | link_export_picture.SetColours("BLACK", "BLACK", "BLACK") |
115 | + link_export_picture.SetBackgroundColour(self.GetBackgroundColour()) | |
113 | 116 | link_export_picture.SetToolTip(tooltip) |
114 | 117 | link_export_picture.AutoBrowse(False) |
115 | 118 | link_export_picture.UpdateLink() |
... | ... | @@ -119,7 +122,9 @@ class InnerTaskPanel(wx.Panel): |
119 | 122 | tooltip = wx.ToolTip(_("Export 3D surface")) |
120 | 123 | link_export_surface = hl.HyperLinkCtrl(self, -1,_("Export 3D surface...")) |
121 | 124 | link_export_surface.SetUnderlines(False, False, False) |
125 | + link_export_surface.SetBold(True) | |
122 | 126 | link_export_surface.SetColours("BLACK", "BLACK", "BLACK") |
127 | + link_export_surface.SetBackgroundColour(self.GetBackgroundColour()) | |
123 | 128 | link_export_surface.SetToolTip(tooltip) |
124 | 129 | link_export_surface.AutoBrowse(False) |
125 | 130 | link_export_surface.UpdateLink() |
... | ... | @@ -160,26 +165,28 @@ class InnerTaskPanel(wx.Panel): |
160 | 165 | if sys.platform == 'darwin': |
161 | 166 | BMP_EXPORT_SURFACE = wx.Bitmap(\ |
162 | 167 | "../icons/surface_export_original.png", |
163 | - wx.BITMAP_TYPE_PNG) | |
168 | + wx.BITMAP_TYPE_PNG).ConvertToImage()\ | |
169 | + .Rescale(25, 25).ConvertToBitmap() | |
164 | 170 | BMP_TAKE_PICTURE = wx.Bitmap(\ |
165 | 171 | "../icons/tool_photo_original.png", |
166 | - wx.BITMAP_TYPE_PNG) | |
172 | + wx.BITMAP_TYPE_PNG).ConvertToImage()\ | |
173 | + .Rescale(25, 25).ConvertToBitmap() | |
174 | + | |
167 | 175 | #BMP_EXPORT_MASK = wx.Bitmap("../icons/mask.png", |
168 | 176 | # wx.BITMAP_TYPE_PNG) |
169 | 177 | else: |
170 | 178 | BMP_EXPORT_SURFACE = wx.Bitmap("../icons/surface_export.png", |
171 | - wx.BITMAP_TYPE_PNG) | |
179 | + wx.BITMAP_TYPE_PNG).ConvertToImage()\ | |
180 | + .Rescale(25, 25).ConvertToBitmap() | |
181 | + | |
172 | 182 | BMP_TAKE_PICTURE = wx.Bitmap("../icons/tool_photo.png", |
173 | - wx.BITMAP_TYPE_PNG) | |
183 | + wx.BITMAP_TYPE_PNG).ConvertToImage()\ | |
184 | + .Rescale(25, 25).ConvertToBitmap() | |
185 | + | |
174 | 186 | #BMP_EXPORT_MASK = wx.Bitmap("../icons/mask_small.png", |
175 | 187 | # wx.BITMAP_TYPE_PNG) |
176 | 188 | |
177 | 189 | |
178 | - bmp_list = [BMP_TAKE_PICTURE, BMP_EXPORT_SURFACE]#, | |
179 | - # BMP_EXPORT_MASK] | |
180 | - for bmp in bmp_list: | |
181 | - bmp.SetWidth(25) | |
182 | - bmp.SetHeight(25) | |
183 | 190 | |
184 | 191 | # Buttons related to hyperlinks |
185 | 192 | button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT |
... | ... | @@ -187,11 +194,13 @@ class InnerTaskPanel(wx.Panel): |
187 | 194 | button_picture = pbtn.PlateButton(self, BTN_PICTURE, "", |
188 | 195 | BMP_TAKE_PICTURE, |
189 | 196 | style=button_style) |
197 | + button_picture.SetBackgroundColour(self.GetBackgroundColour()) | |
190 | 198 | self.button_picture = button_picture |
191 | 199 | |
192 | 200 | button_surface = pbtn.PlateButton(self, BTN_SURFACE, "", |
193 | 201 | BMP_EXPORT_SURFACE, |
194 | 202 | style=button_style) |
203 | + button_surface.SetBackgroundColour(self.GetBackgroundColour()) | |
195 | 204 | #button_mask = pbtn.PlateButton(self, BTN_MASK, "", |
196 | 205 | # BMP_EXPORT_MASK, |
197 | 206 | # style=button_style) |
... | ... | @@ -232,7 +241,7 @@ class InnerTaskPanel(wx.Panel): |
232 | 241 | self.__init_menu() |
233 | 242 | |
234 | 243 | def __init_menu(self): |
235 | - | |
244 | + | |
236 | 245 | |
237 | 246 | menu = wx.Menu() |
238 | 247 | self.id_to_name = {const.AXIAL:_("Axial slice"), |
... | ... | @@ -244,23 +253,23 @@ class InnerTaskPanel(wx.Panel): |
244 | 253 | item = wx.MenuItem(menu, id, self.id_to_name[id]) |
245 | 254 | menu.AppendItem(item) |
246 | 255 | |
247 | - self.menu_picture = menu | |
256 | + self.menu_picture = menu | |
248 | 257 | menu.Bind(wx.EVT_MENU, self.OnMenuPicture) |
249 | 258 | |
250 | 259 | def OnMenuPicture(self, evt): |
251 | - print "OnMenuPicture" | |
260 | + print "OnMenuPicture" | |
252 | 261 | id = evt.GetId() |
253 | 262 | value = dlg.ExportPicture(self.id_to_name[id]) |
254 | 263 | if value: |
255 | - filename, filetype = value | |
264 | + filename, filetype = value | |
256 | 265 | Publisher.sendMessage('Export picture to file', |
257 | 266 | (id, filename, filetype)) |
258 | - | |
267 | + | |
259 | 268 | |
260 | 269 | |
261 | 270 | def OnLinkExportPicture(self, evt=None): |
262 | 271 | self.button_picture.PopupMenu(self.menu_picture) |
263 | - | |
272 | + | |
264 | 273 | |
265 | 274 | def OnLinkExportMask(self, evt=None): |
266 | 275 | project = proj.Project() |
... | ... | @@ -276,9 +285,9 @@ class InnerTaskPanel(wx.Panel): |
276 | 285 | "", # last used directory |
277 | 286 | project_name, # filename |
278 | 287 | WILDCARD_SAVE_MASK, |
279 | - wx.SAVE|wx.OVERWRITE_PROMPT) | |
288 | + wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) | |
280 | 289 | dlg.SetFilterIndex(0) # default is VTI |
281 | - | |
290 | + | |
282 | 291 | if dlg.ShowModal() == wx.ID_OK: |
283 | 292 | filename = dlg.GetPath() |
284 | 293 | print "filename", filename |
... | ... | @@ -312,9 +321,9 @@ class InnerTaskPanel(wx.Panel): |
312 | 321 | "", # last used directory |
313 | 322 | project_name, # filename |
314 | 323 | WILDCARD_SAVE_3D, |
315 | - wx.SAVE|wx.OVERWRITE_PROMPT) | |
324 | + wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) | |
316 | 325 | dlg.SetFilterIndex(3) # default is STL |
317 | - | |
326 | + | |
318 | 327 | if dlg.ShowModal() == wx.ID_OK: |
319 | 328 | filetype_index = dlg.GetFilterIndex() |
320 | 329 | filetype = INDEX_TO_TYPE_3D[filetype_index] | ... | ... |
invesalius/gui/task_importer.py
... | ... | @@ -51,7 +51,10 @@ class TaskPanel(wx.Panel): |
51 | 51 | class InnerTaskPanel(wx.Panel): |
52 | 52 | def __init__(self, parent): |
53 | 53 | wx.Panel.__init__(self, parent) |
54 | - self.SetBackgroundColour(wx.Colour(255,255,255)) | |
54 | + | |
55 | + backgroud_colour = wx.Colour(255,255,255) | |
56 | + | |
57 | + self.SetBackgroundColour(backgroud_colour) | |
55 | 58 | self.SetAutoLayout(1) |
56 | 59 | |
57 | 60 | # Counter for projects loaded in current GUI |
... | ... | @@ -64,7 +67,9 @@ class InnerTaskPanel(wx.Panel): |
64 | 67 | tooltip = wx.ToolTip(_("Select DICOM or Analyze files to be reconstructed")) |
65 | 68 | link_import_local = hl.HyperLinkCtrl(self, -1, _("Import medical images...")) |
66 | 69 | link_import_local.SetUnderlines(False, False, False) |
70 | + link_import_local.SetBold(True) | |
67 | 71 | link_import_local.SetColours("BLACK", "BLACK", "BLACK") |
72 | + link_import_local.SetBackgroundColour(backgroud_colour) | |
68 | 73 | link_import_local.SetToolTip(tooltip) |
69 | 74 | link_import_local.AutoBrowse(False) |
70 | 75 | link_import_local.UpdateLink() |
... | ... | @@ -82,7 +87,9 @@ class InnerTaskPanel(wx.Panel): |
82 | 87 | tooltip = wx.ToolTip(_("Open an existing InVesalius project...")) |
83 | 88 | link_open_proj = hl.HyperLinkCtrl(self,-1,_("Open an existing project...")) |
84 | 89 | link_open_proj.SetUnderlines(False, False, False) |
90 | + link_open_proj.SetBold(True) | |
85 | 91 | link_open_proj.SetColours("BLACK", "BLACK", "BLACK") |
92 | + link_open_proj.SetBackgroundColour(backgroud_colour) | |
86 | 93 | link_open_proj.SetToolTip(tooltip) |
87 | 94 | link_open_proj.AutoBrowse(False) |
88 | 95 | link_open_proj.UpdateLink() |
... | ... | @@ -94,9 +101,9 @@ class InnerTaskPanel(wx.Panel): |
94 | 101 | BMP_OPEN_PROJECT = wx.Bitmap("../icons/file_open.png", wx.BITMAP_TYPE_PNG) |
95 | 102 | |
96 | 103 | bmp_list = [BMP_IMPORT, BMP_NET, BMP_OPEN_PROJECT] |
97 | - for bmp in bmp_list: | |
98 | - bmp.SetWidth(25) | |
99 | - bmp.SetHeight(25) | |
104 | + #for bmp in bmp_list: | |
105 | + #bmp.SetWidth(25) | |
106 | + #bmp.SetHeight(25) | |
100 | 107 | |
101 | 108 | # Buttons related to hyperlinks |
102 | 109 | button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT |
... | ... | @@ -105,8 +112,10 @@ class InnerTaskPanel(wx.Panel): |
105 | 112 | # style=button_style) |
106 | 113 | button_import_local = pbtn.PlateButton(self, BTN_IMPORT_LOCAL, "", |
107 | 114 | BMP_IMPORT, style=button_style) |
115 | + button_import_local.SetBackgroundColour(self.GetBackgroundColour()) | |
108 | 116 | button_open_proj = pbtn.PlateButton(self, BTN_OPEN_PROJECT, "", |
109 | 117 | BMP_OPEN_PROJECT, style=button_style) |
118 | + button_open_proj.SetBackgroundColour(self.GetBackgroundColour()) | |
110 | 119 | |
111 | 120 | # When using PlaneButton, it is necessary to bind events from parent win |
112 | 121 | self.Bind(wx.EVT_BUTTON, self.OnButton) |
... | ... | @@ -185,6 +194,7 @@ class InnerTaskPanel(wx.Panel): |
185 | 194 | proj_link = hl.HyperLinkCtrl(self, -1, label) |
186 | 195 | proj_link.SetUnderlines(False, False, False) |
187 | 196 | proj_link.SetColours("BLACK", "BLACK", "BLACK") |
197 | + proj_link.SetBackgroundColour(self.GetBackgroundColour()) | |
188 | 198 | proj_link.AutoBrowse(False) |
189 | 199 | proj_link.UpdateLink() |
190 | 200 | proj_link.Bind(hl.EVT_HYPERLINK_LEFT, |
... | ... | @@ -201,7 +211,7 @@ class InnerTaskPanel(wx.Panel): |
201 | 211 | def OnLinkImport(self, event): |
202 | 212 | self.ImportDicom() |
203 | 213 | event.Skip() |
204 | - | |
214 | + | |
205 | 215 | def OnLinkImportPACS(self, event): |
206 | 216 | self.ImportPACS() |
207 | 217 | event.Skip() |
... | ... | @@ -210,7 +220,7 @@ class InnerTaskPanel(wx.Panel): |
210 | 220 | self.OpenProject() |
211 | 221 | event.Skip() |
212 | 222 | |
213 | - | |
223 | + | |
214 | 224 | def ImportPACS(self): |
215 | 225 | print "TODO: Send Signal - Import DICOM files from PACS" |
216 | 226 | ... | ... |
invesalius/gui/task_slice.py
... | ... | @@ -65,17 +65,19 @@ class TaskPanel(wx.Panel): |
65 | 65 | class InnerTaskPanel(wx.Panel): |
66 | 66 | def __init__(self, parent): |
67 | 67 | wx.Panel.__init__(self, parent) |
68 | - self.SetBackgroundColour(wx.Colour(255,255,255)) | |
68 | + backgroud_colour = wx.Colour(255,255,255) | |
69 | + self.SetBackgroundColour(backgroud_colour) | |
69 | 70 | self.SetAutoLayout(1) |
70 | 71 | |
71 | 72 | # Image(s) for buttons |
72 | 73 | BMP_ADD = wx.Bitmap("../icons/object_add.png", wx.BITMAP_TYPE_PNG) |
73 | - BMP_ADD.SetWidth(25) | |
74 | - BMP_ADD.SetHeight(25) | |
74 | + #BMP_ADD.SetWidth(25) | |
75 | + #BMP_ADD.SetHeight(25) | |
75 | 76 | |
76 | 77 | # Button for creating new surface |
77 | 78 | button_new_mask = pbtn.PlateButton(self, BTN_NEW, "", BMP_ADD, style=\ |
78 | 79 | pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT) |
80 | + button_new_mask.SetBackgroundColour(self.GetBackgroundColour()) | |
79 | 81 | self.Bind(wx.EVT_BUTTON, self.OnButton) |
80 | 82 | |
81 | 83 | |
... | ... | @@ -83,7 +85,9 @@ class InnerTaskPanel(wx.Panel): |
83 | 85 | tooltip = wx.ToolTip(_("Create mask for slice segmentation and editing")) |
84 | 86 | link_new_mask = hl.HyperLinkCtrl(self, -1, _("Create new mask")) |
85 | 87 | link_new_mask.SetUnderlines(False, False, False) |
88 | + link_new_mask.SetBold(True) | |
86 | 89 | link_new_mask.SetColours("BLACK", "BLACK", "BLACK") |
90 | + link_new_mask.SetBackgroundColour(self.GetBackgroundColour()) | |
87 | 91 | link_new_mask.SetToolTip(tooltip) |
88 | 92 | link_new_mask.AutoBrowse(False) |
89 | 93 | link_new_mask.UpdateLink() |
... | ... | @@ -117,20 +121,23 @@ class InnerTaskPanel(wx.Panel): |
117 | 121 | check_box.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) |
118 | 122 | button_next.Bind(wx.EVT_BUTTON, self.OnButtonNextTask) |
119 | 123 | |
124 | + next_btn_sizer = wx.BoxSizer(wx.VERTICAL) | |
125 | + next_btn_sizer.Add(button_next, 1, wx.ALIGN_RIGHT) | |
126 | + | |
120 | 127 | line_sizer = wx.BoxSizer(wx.HORIZONTAL) |
121 | - line_sizer.Add(check_box, 1, wx.ALIGN_LEFT|wx.RIGHT|wx.LEFT|wx.BOTTOM, 5) | |
122 | - line_sizer.Add(button_next, 0, | |
123 | - wx.ALIGN_RIGHT|wx.RIGHT|wx.LEFT|wx.BOTTOM, 5) | |
128 | + line_sizer.Add(check_box, 0, wx.ALIGN_LEFT|wx.RIGHT|wx.LEFT, 5) | |
129 | + line_sizer.Add(next_btn_sizer, 1, wx.EXPAND|wx.ALIGN_RIGHT|wx.RIGHT|wx.LEFT, 5) | |
124 | 130 | line_sizer.Fit(self) |
125 | 131 | |
126 | 132 | # Add line sizers into main sizer |
127 | 133 | main_sizer = wx.BoxSizer(wx.VERTICAL) |
128 | 134 | main_sizer.Add(line_new, 0,wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) |
129 | - main_sizer.Add(fold_panel, 6, wx.GROW|wx.EXPAND|wx.ALL, 5) | |
130 | - main_sizer.AddSizer(line_sizer, 1, wx.GROW|wx.EXPAND) | |
135 | + main_sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND|wx.ALL, 5) | |
136 | + main_sizer.AddSizer(line_sizer, 0, wx.GROW|wx.EXPAND) | |
137 | + main_sizer.AddSpacer(5) | |
131 | 138 | main_sizer.Fit(self) |
132 | 139 | |
133 | - self.SetSizer(main_sizer) | |
140 | + self.SetSizerAndFit(main_sizer) | |
134 | 141 | self.Update() |
135 | 142 | self.SetAutoLayout(1) |
136 | 143 | |
... | ... | @@ -161,7 +168,7 @@ class InnerTaskPanel(wx.Panel): |
161 | 168 | |
162 | 169 | if to_generate: |
163 | 170 | mask_index = sl.current_mask.index |
164 | - method = {'algorithm': algorithm, | |
171 | + method = {'algorithm': algorithm, | |
165 | 172 | 'options': options} |
166 | 173 | srf_options = {"index": mask_index, |
167 | 174 | "name": '', |
... | ... | @@ -170,7 +177,7 @@ class InnerTaskPanel(wx.Panel): |
170 | 177 | "keep_largest": False, |
171 | 178 | "overwrite": overwrite} |
172 | 179 | |
173 | - Publisher.sendMessage('Create surface from index', | |
180 | + Publisher.sendMessage('Create surface from index', | |
174 | 181 | {'method': method, 'options': srf_options}) |
175 | 182 | Publisher.sendMessage('Fold surface task') |
176 | 183 | |
... | ... | @@ -200,8 +207,7 @@ class InnerTaskPanel(wx.Panel): |
200 | 207 | |
201 | 208 | class FoldPanel(wx.Panel): |
202 | 209 | def __init__(self, parent): |
203 | - wx.Panel.__init__(self, parent, size=(50,50)) | |
204 | - self.SetBackgroundColour(wx.Colour(0,255,0)) | |
210 | + wx.Panel.__init__(self, parent) | |
205 | 211 | |
206 | 212 | inner_panel = InnerFoldPanel(self) |
207 | 213 | |
... | ... | @@ -209,7 +215,7 @@ class FoldPanel(wx.Panel): |
209 | 215 | sizer.Add(inner_panel, 1, wx.EXPAND|wx.GROW, 2) |
210 | 216 | sizer.Fit(self) |
211 | 217 | |
212 | - self.SetSizer(sizer) | |
218 | + self.SetSizerAndFit(sizer) | |
213 | 219 | self.Update() |
214 | 220 | self.SetAutoLayout(1) |
215 | 221 | |
... | ... | @@ -231,8 +237,24 @@ class InnerFoldPanel(wx.Panel): |
231 | 237 | # is not working properly in this panel. It might be on some child or |
232 | 238 | # parent panel. Perhaps we need to insert the item into the sizer also... |
233 | 239 | # Study this. |
240 | + #gbs = wx.GridBagSizer() | |
241 | + | |
242 | + #gbs.AddGrowableRow(0, 1) | |
243 | + #gbs.AddGrowableCol(0, 1) | |
244 | + | |
245 | + #self.gbs = gbs | |
246 | + | |
247 | + self.last_size = None | |
248 | + | |
249 | + # Panel sizer to expand fold panel | |
250 | + sizer = wx.BoxSizer(wx.VERTICAL) | |
251 | + #sizer.Add(gbs, 1, wx.GROW|wx.EXPAND) | |
252 | + self.SetSizer(sizer) | |
253 | + | |
234 | 254 | fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, |
235 | - (10, 220), 0,fpb.FPB_SINGLE_FOLD) | |
255 | + wx.DefaultSize, 0,fpb.FPB_SINGLE_FOLD) | |
256 | + self.fold_panel = fold_panel | |
257 | + | |
236 | 258 | |
237 | 259 | # Fold panel style |
238 | 260 | style = fpb.CaptionBarStyle() |
... | ... | @@ -243,35 +265,38 @@ class InnerFoldPanel(wx.Panel): |
243 | 265 | # Fold 1 - Mask properties |
244 | 266 | item = fold_panel.AddFoldPanel(_("Mask properties"), collapsed=True) |
245 | 267 | self.mask_prop_panel = MaskProperties(item) |
268 | + | |
246 | 269 | fold_panel.ApplyCaptionStyle(item, style) |
247 | 270 | fold_panel.AddFoldPanelWindow(item, self.mask_prop_panel, Spacing= 0, |
248 | 271 | leftSpacing=0, rightSpacing=0) |
249 | - fold_panel.Expand(fold_panel.GetFoldPanel(0)) | |
250 | 272 | |
251 | 273 | # Fold 2 - Advanced edition tools |
252 | 274 | item = fold_panel.AddFoldPanel(_("Advanced editing tools"), collapsed=True) |
275 | + etw = EditionTools(item) | |
276 | + | |
253 | 277 | fold_panel.ApplyCaptionStyle(item, style) |
254 | - fold_panel.AddFoldPanelWindow(item, EditionTools(item), Spacing= 0, | |
278 | + fold_panel.AddFoldPanelWindow(item, etw, Spacing= 0, | |
255 | 279 | leftSpacing=0, rightSpacing=0) |
256 | 280 | self.__id_editor = item.GetId() |
257 | 281 | self.last_panel_opened = None |
258 | 282 | |
259 | 283 | # Fold 3 - Watershed |
260 | 284 | item = fold_panel.AddFoldPanel(_("Watershed"), collapsed=True) |
285 | + wtw = WatershedTool(item) | |
286 | + | |
261 | 287 | fold_panel.ApplyCaptionStyle(item, style) |
262 | - fold_panel.AddFoldPanelWindow(item, WatershedTool(item), Spacing= 0, | |
288 | + fold_panel.AddFoldPanelWindow(item, wtw, Spacing= 0, | |
263 | 289 | leftSpacing=0, rightSpacing=0) |
264 | 290 | self.__id_watershed = item.GetId() |
265 | 291 | |
266 | - #fold_panel.Expand(fold_panel.GetFoldPanel(1)) | |
292 | + sizer.Add(fold_panel, 1, wx.EXPAND) | |
267 | 293 | |
268 | - # Panel sizer to expand fold panel | |
269 | - sizer = wx.BoxSizer(wx.VERTICAL) | |
270 | - sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) | |
271 | - sizer.Fit(self) | |
272 | - self.SetSizer(sizer) | |
273 | - self.Update() | |
274 | - self.SetAutoLayout(1) | |
294 | + fold_panel.Expand(fold_panel.GetFoldPanel(2)) | |
295 | + self.ResizeFPB() | |
296 | + fold_panel.Expand(fold_panel.GetFoldPanel(0)) | |
297 | + | |
298 | + sizer.Layout() | |
299 | + self.Fit() | |
275 | 300 | |
276 | 301 | self.fold_panel = fold_panel |
277 | 302 | self.last_style = None |
... | ... | @@ -279,6 +304,39 @@ class InnerFoldPanel(wx.Panel): |
279 | 304 | self.__bind_evt() |
280 | 305 | self.__bind_pubsub_evt() |
281 | 306 | |
307 | + def __calc_best_size(self, panel): | |
308 | + print "Best size", self.GetSize() | |
309 | + parent = panel.GetParent() | |
310 | + q = panel.Reparent(self) | |
311 | + | |
312 | + #gbs = self.gbs | |
313 | + fold_panel = self.fold_panel | |
314 | + | |
315 | + # Calculating the size | |
316 | + #gbs.AddGrowableRow(0, 1) | |
317 | + #gbs.AddGrowableRow(0, 1) | |
318 | + #gbs.Add(panel, (0, 0), flag=wx.EXPAND) | |
319 | + self.GetSizer().Add(panel, 1, wx.EXPAND) | |
320 | + #self.SetSizerAndFit(self.GetSizer()) | |
321 | + self.GetSizer().Layout() | |
322 | + self.GetSizer().Fit(self) | |
323 | + #gbs.Layout() | |
324 | + #self.Fit() | |
325 | + #self.GetSizer().Layout() | |
326 | + size = panel.GetSize() | |
327 | + | |
328 | + #gbs.Remove(0) | |
329 | + #gbs.RemoveGrowableRow(0) | |
330 | + | |
331 | + self.GetSizer().Remove(0) | |
332 | + panel.Reparent(parent) | |
333 | + panel.SetInitialSize(size) | |
334 | + | |
335 | + #if self.last_size is None or self.last_size.GetHeight() < size.GetHeight(): | |
336 | + #self.SetInitialSize(size) | |
337 | + | |
338 | + print "Best size", size, self.GetSize(), self.GetClientSize(), q | |
339 | + | |
282 | 340 | def __bind_evt(self): |
283 | 341 | self.fold_panel.Bind(fpb.EVT_CAPTIONBAR, self.OnFoldPressCaption) |
284 | 342 | |
... | ... | @@ -313,6 +371,13 @@ class InnerFoldPanel(wx.Panel): |
313 | 371 | self.last_style = None |
314 | 372 | |
315 | 373 | evt.Skip() |
374 | + wx.CallAfter(self.ResizeFPB) | |
375 | + | |
376 | + | |
377 | + def ResizeFPB(self): | |
378 | + sizeNeeded = self.fold_panel.GetPanelsLength(0, 0)[2] | |
379 | + self.fold_panel.SetMinSize((self.fold_panel.GetSize()[0], sizeNeeded )) | |
380 | + self.fold_panel.SetSize((self.fold_panel.GetSize()[0], sizeNeeded)) | |
316 | 381 | |
317 | 382 | def OnRetrieveStyle(self, pubsub_evt): |
318 | 383 | if (self.last_style == const.SLICE_STATE_EDITOR): |
... | ... | @@ -331,14 +396,14 @@ class InnerFoldPanel(wx.Panel): |
331 | 396 | |
332 | 397 | class MaskProperties(wx.Panel): |
333 | 398 | def __init__(self, parent): |
334 | - wx.Panel.__init__(self, parent, size=(50,240)) | |
399 | + wx.Panel.__init__(self, parent) | |
335 | 400 | |
336 | 401 | ## LINE 1 |
337 | 402 | |
338 | 403 | # Combo related to mask naem |
339 | 404 | combo_mask_name = wx.ComboBox(self, -1, "", choices= MASK_LIST, |
340 | 405 | style=wx.CB_DROPDOWN|wx.CB_READONLY) |
341 | - combo_mask_name.SetSelection(0) # wx.CB_SORT | |
406 | + #combo_mask_name.SetSelection(0) # wx.CB_SORT | |
342 | 407 | if sys.platform != 'win32': |
343 | 408 | combo_mask_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) |
344 | 409 | self.combo_mask_name = combo_mask_name |
... | ... | @@ -350,21 +415,23 @@ class MaskProperties(wx.Panel): |
350 | 415 | # Sizer which represents the first line |
351 | 416 | line1 = wx.BoxSizer(wx.HORIZONTAL) |
352 | 417 | line1.Add(combo_mask_name, 1, wx.EXPAND|wx.GROW|wx.TOP|wx.RIGHT, 2) |
353 | - line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT, 2) | |
418 | + line1.Add(button_colour, 0, wx.TOP|wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL , 2) | |
354 | 419 | |
355 | - ## LINE 2 | |
420 | + ### LINE 2 | |
356 | 421 | text_thresh = wx.StaticText(self, -1, |
357 | 422 | _("Set predefined or manual threshold:")) |
358 | 423 | |
359 | - ## LINE 3 | |
360 | - combo_thresh = wx.ComboBox(self, -1, "", size=(15,-1), | |
361 | - choices=[],#THRESHOLD_LIST | |
424 | + ### LINE 3 | |
425 | + THRESHOLD_LIST = ["",] | |
426 | + combo_thresh = wx.ComboBox(self, -1, "", #size=(15,-1), | |
427 | + choices=THRESHOLD_LIST, | |
362 | 428 | style=wx.CB_DROPDOWN|wx.CB_READONLY) |
363 | 429 | combo_thresh.SetSelection(0) |
364 | 430 | if sys.platform != 'win32': |
365 | 431 | combo_thresh.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) |
366 | 432 | self.combo_thresh = combo_thresh |
367 | 433 | |
434 | + | |
368 | 435 | ## LINE 4 |
369 | 436 | gradient = grad.GradientCtrl(self, -1, -5000, 5000, 0, 5000, |
370 | 437 | (0, 255, 0, 100)) |
... | ... | @@ -372,13 +439,21 @@ class MaskProperties(wx.Panel): |
372 | 439 | |
373 | 440 | # Add all lines into main sizer |
374 | 441 | sizer = wx.BoxSizer(wx.VERTICAL) |
375 | - sizer.Add(line1, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) | |
376 | - sizer.Add(text_thresh, 1, wx.GROW|wx.EXPAND|wx.ALL, 5) | |
377 | - sizer.Add(combo_thresh, 1, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
378 | - sizer.Add(gradient, 1, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT|wx.BOTTOM, 6) | |
442 | + sizer.AddSpacer(7) | |
443 | + sizer.Add(line1, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
444 | + | |
445 | + sizer.AddSpacer(5) | |
446 | + sizer.Add(text_thresh, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
447 | + sizer.AddSpacer(2) | |
448 | + sizer.Add(combo_thresh, 0, wx.EXPAND|wx.GROW|wx.LEFT|wx.RIGHT, 5) | |
449 | + | |
450 | + sizer.AddSpacer(5) | |
451 | + sizer.Add(gradient, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
452 | + sizer.AddSpacer(7) | |
453 | + | |
379 | 454 | sizer.Fit(self) |
380 | 455 | |
381 | - self.SetSizer(sizer) | |
456 | + self.SetSizerAndFit(sizer) | |
382 | 457 | self.Update() |
383 | 458 | self.SetAutoLayout(1) |
384 | 459 | |
... | ... | @@ -417,7 +492,7 @@ class MaskProperties(wx.Panel): |
417 | 492 | n = self.combo_thresh.GetCount() |
418 | 493 | for i in xrange(n-1, -1, -1): |
419 | 494 | self.combo_thresh.Delete(i) |
420 | - | |
495 | + | |
421 | 496 | def OnRemoveMasks(self, pubsub_evt): |
422 | 497 | print "OnRemoveMasks" |
423 | 498 | list_index = pubsub_evt.data |
... | ... | @@ -457,7 +532,7 @@ class MaskProperties(wx.Panel): |
457 | 532 | thresh = (thresh_min, thresh_max) |
458 | 533 | if thresh in Project().threshold_modes.values(): |
459 | 534 | preset_name = Project().threshold_modes.get_key(thresh)[0] |
460 | - index = self.threshold_modes_names.index(preset_name) | |
535 | + index = self.threshold_modes_names.index(preset_name) | |
461 | 536 | self.combo_thresh.SetSelection(index) |
462 | 537 | else: |
463 | 538 | index = self.threshold_modes_names.index(_("Custom")) |
... | ... | @@ -471,7 +546,7 @@ class MaskProperties(wx.Panel): |
471 | 546 | thresh = (thresh_min, thresh_max) |
472 | 547 | if thresh in Project().threshold_modes.values(): |
473 | 548 | preset_name = Project().threshold_modes.get_key(thresh)[0] |
474 | - index = self.threshold_modes_names.index(preset_name) | |
549 | + index = self.threshold_modes_names.index(preset_name) | |
475 | 550 | self.combo_thresh.SetSelection(index) |
476 | 551 | else: |
477 | 552 | index = self.threshold_modes_names.index(_("Custom")) |
... | ... | @@ -515,7 +590,7 @@ class MaskProperties(wx.Panel): |
515 | 590 | |
516 | 591 | elif default_thresh in proj.threshold_modes.values(): |
517 | 592 | preset_name = proj.threshold_modes.get_key(default_thresh)[0] |
518 | - index = self.threshold_modes_names.index(preset_name) | |
593 | + index = self.threshold_modes_names.index(preset_name) | |
519 | 594 | self.combo_thresh.SetSelection(index) |
520 | 595 | thresh_min, thresh_max = default_thresh |
521 | 596 | else: |
... | ... | @@ -569,7 +644,7 @@ class MaskProperties(wx.Panel): |
569 | 644 | |
570 | 645 | class EditionTools(wx.Panel): |
571 | 646 | def __init__(self, parent): |
572 | - wx.Panel.__init__(self, parent, size=(50,240)) | |
647 | + wx.Panel.__init__(self, parent) | |
573 | 648 | default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) |
574 | 649 | self.SetBackgroundColour(default_colour) |
575 | 650 | |
... | ... | @@ -599,7 +674,12 @@ class EditionTools(wx.Panel): |
599 | 674 | btn_brush_format.SetMenu(menu) |
600 | 675 | self.btn_brush_format = btn_brush_format |
601 | 676 | |
602 | - spin_brush_size = wx.SpinCtrl(self, -1, "", (20, 50)) | |
677 | + # To calculate best width to spinctrl | |
678 | + dc = wx.WindowDC(self) | |
679 | + dc.SetFont(self.GetFont()) | |
680 | + width, height = dc.GetTextExtent("MMM") | |
681 | + | |
682 | + spin_brush_size = wx.SpinCtrl(self, -1, "", size=(width + 20, -1)) | |
603 | 683 | spin_brush_size.SetRange(1,100) |
604 | 684 | spin_brush_size.SetValue(const.BRUSH_SIZE) |
605 | 685 | spin_brush_size.Bind(wx.EVT_TEXT, self.OnBrushSize) |
... | ... | @@ -615,9 +695,9 @@ class EditionTools(wx.Panel): |
615 | 695 | |
616 | 696 | # Sizer which represents the second line |
617 | 697 | line2 = wx.BoxSizer(wx.HORIZONTAL) |
618 | - line2.Add(btn_brush_format, 0, wx.EXPAND|wx.GROW|wx.TOP|wx.RIGHT, 0) | |
619 | - line2.Add(spin_brush_size, 0, wx.RIGHT, 5) | |
620 | - line2.Add(combo_brush_op, 1, wx.EXPAND|wx.TOP|wx.RIGHT|wx.LEFT, 5) | |
698 | + line2.Add(btn_brush_format, 0, wx.EXPAND|wx.GROW|wx.RIGHT, 5) | |
699 | + line2.Add(spin_brush_size, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 5) | |
700 | + line2.Add(combo_brush_op, 1, wx.RIGHT|wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 5) | |
621 | 701 | |
622 | 702 | ## LINE 3 |
623 | 703 | text_thresh = wx.StaticText(self, -1, _("Brush threshold range:")) |
... | ... | @@ -630,14 +710,18 @@ class EditionTools(wx.Panel): |
630 | 710 | |
631 | 711 | # Add lines into main sizer |
632 | 712 | sizer = wx.BoxSizer(wx.VERTICAL) |
633 | - sizer.Add(text1, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) | |
634 | - sizer.Add(line2, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) | |
635 | - sizer.Add(text_thresh, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) | |
636 | - sizer.Add(gradient_thresh, 0, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT| | |
637 | - wx.BOTTOM, 6) | |
713 | + sizer.AddSpacer(7) | |
714 | + sizer.Add(text1, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
715 | + sizer.AddSpacer(2) | |
716 | + sizer.Add(line2, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
717 | + sizer.AddSpacer(5) | |
718 | + sizer.Add(text_thresh, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
719 | + sizer.AddSpacer(5) | |
720 | + sizer.Add(gradient_thresh, 0, wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
721 | + sizer.AddSpacer(7) | |
638 | 722 | sizer.Fit(self) |
639 | 723 | |
640 | - self.SetSizer(sizer) | |
724 | + self.SetSizerAndFit(sizer) | |
641 | 725 | self.Update() |
642 | 726 | self.SetAutoLayout(1) |
643 | 727 | |
... | ... | @@ -715,7 +799,7 @@ class EditionTools(wx.Panel): |
715 | 799 | |
716 | 800 | class WatershedTool(EditionTools): |
717 | 801 | def __init__(self, parent): |
718 | - wx.Panel.__init__(self, parent, size=(50,150)) | |
802 | + wx.Panel.__init__(self, parent) | |
719 | 803 | default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) |
720 | 804 | self.SetBackgroundColour(default_colour) |
721 | 805 | |
... | ... | @@ -745,7 +829,12 @@ class WatershedTool(EditionTools): |
745 | 829 | btn_brush_format.SetMenu(menu) |
746 | 830 | self.btn_brush_format = btn_brush_format |
747 | 831 | |
748 | - spin_brush_size = wx.SpinCtrl(self, -1, "", (20, 50)) | |
832 | + # To calculate best width to spinctrl | |
833 | + dc = wx.WindowDC(self) | |
834 | + dc.SetFont(self.GetFont()) | |
835 | + width, height = dc.GetTextExtent("MMM") | |
836 | + | |
837 | + spin_brush_size = wx.SpinCtrl(self, -1, "", size=(width + 20, -1)) | |
749 | 838 | spin_brush_size.SetRange(1,100) |
750 | 839 | spin_brush_size.SetValue(const.BRUSH_SIZE) |
751 | 840 | spin_brush_size.Bind(wx.EVT_TEXT, self.OnBrushSize) |
... | ... | @@ -763,9 +852,9 @@ class WatershedTool(EditionTools): |
763 | 852 | |
764 | 853 | # Sizer which represents the second line |
765 | 854 | line2 = wx.BoxSizer(wx.HORIZONTAL) |
766 | - line2.Add(btn_brush_format, 0, wx.EXPAND|wx.GROW|wx.TOP|wx.RIGHT, 0) | |
767 | - line2.Add(spin_brush_size, 0, wx.RIGHT, 5) | |
768 | - line2.Add(combo_brush_op, 1, wx.EXPAND|wx.TOP|wx.RIGHT|wx.LEFT, 5) | |
855 | + line2.Add(btn_brush_format, 0, wx.EXPAND|wx.GROW|wx.RIGHT, 5) | |
856 | + line2.Add(spin_brush_size, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 5) | |
857 | + line2.Add(combo_brush_op, 1, wx.RIGHT|wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 5) | |
769 | 858 | |
770 | 859 | ## LINE 3 |
771 | 860 | |
... | ... | @@ -790,14 +879,20 @@ class WatershedTool(EditionTools): |
790 | 879 | |
791 | 880 | # Add lines into main sizer |
792 | 881 | sizer = wx.BoxSizer(wx.VERTICAL) |
793 | - sizer.Add(text1, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) | |
794 | - sizer.Add(line2, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) | |
795 | - sizer.Add(check_box, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) | |
796 | - sizer.Add(ww_wl_cbox, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) | |
882 | + sizer.AddSpacer(7) | |
883 | + sizer.Add(text1, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
884 | + sizer.AddSpacer(2) | |
885 | + sizer.Add(line2, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
886 | + sizer.AddSpacer(5) | |
887 | + sizer.Add(check_box, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
888 | + sizer.AddSpacer(2) | |
889 | + sizer.Add(ww_wl_cbox, 0, wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT, 5) | |
890 | + sizer.AddSpacer(5) | |
797 | 891 | sizer.Add(sizer_btns, 0, wx.EXPAND) |
892 | + sizer.AddSpacer(7) | |
798 | 893 | sizer.Fit(self) |
799 | 894 | |
800 | - self.SetSizer(sizer) | |
895 | + self.SetSizerAndFit(sizer) | |
801 | 896 | self.Update() |
802 | 897 | self.SetAutoLayout(1) |
803 | 898 | ... | ... |
invesalius/gui/task_surface.py
... | ... | @@ -49,8 +49,8 @@ class TaskPanel(wx.Panel): |
49 | 49 | |
50 | 50 | inner_panel = InnerTaskPanel(self) |
51 | 51 | |
52 | - sizer = wx.BoxSizer(wx.HORIZONTAL) | |
53 | - sizer.Add(inner_panel, 1, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT | | |
52 | + sizer = wx.BoxSizer(wx.VERTICAL) | |
53 | + sizer.Add(inner_panel, 0, wx.EXPAND | wx.GROW | wx.BOTTOM | wx.RIGHT | | |
54 | 54 | wx.LEFT, 7) |
55 | 55 | sizer.Fit(self) |
56 | 56 | |
... | ... | @@ -68,24 +68,28 @@ class InnerTaskPanel(wx.Panel): |
68 | 68 | def __init__(self, parent): |
69 | 69 | wx.Panel.__init__(self, parent) |
70 | 70 | default_colour = self.GetBackgroundColour() |
71 | - self.SetBackgroundColour(wx.Colour(255,255,255)) | |
71 | + backgroud_colour = wx.Colour(255,255,255) | |
72 | + self.SetBackgroundColour(backgroud_colour) | |
72 | 73 | self.SetAutoLayout(1) |
73 | 74 | |
74 | 75 | |
75 | 76 | BMP_ADD = wx.Bitmap("../icons/object_add.png", wx.BITMAP_TYPE_PNG) |
76 | - BMP_ADD.SetWidth(25) | |
77 | - BMP_ADD.SetHeight(25) | |
77 | + #BMP_ADD.SetWidth(25) | |
78 | + #BMP_ADD.SetHeight(25) | |
78 | 79 | |
79 | 80 | # Button for creating new surface |
80 | 81 | button_new_surface = pbtn.PlateButton(self, BTN_NEW, "", BMP_ADD, style=\ |
81 | 82 | pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT) |
83 | + button_new_surface.SetBackgroundColour(self.GetBackgroundColour()) | |
82 | 84 | self.Bind(wx.EVT_BUTTON, self.OnButton) |
83 | 85 | |
84 | 86 | # Fixed hyperlink items |
85 | 87 | tooltip = wx.ToolTip(_("Create 3D surface based on a mask")) |
86 | 88 | link_new_surface = hl.HyperLinkCtrl(self, -1, _("Create new 3D surface")) |
87 | 89 | link_new_surface.SetUnderlines(False, False, False) |
90 | + link_new_surface.SetBold(True) | |
88 | 91 | link_new_surface.SetColours("BLACK", "BLACK", "BLACK") |
92 | + link_new_surface.SetBackgroundColour(self.GetBackgroundColour()) | |
89 | 93 | link_new_surface.SetToolTip(tooltip) |
90 | 94 | link_new_surface.AutoBrowse(False) |
91 | 95 | link_new_surface.UpdateLink() |
... | ... | @@ -109,13 +113,13 @@ class InnerTaskPanel(wx.Panel): |
109 | 113 | # Add line sizers into main sizer |
110 | 114 | main_sizer = wx.BoxSizer(wx.VERTICAL) |
111 | 115 | main_sizer.Add(line_new, 0,wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) |
112 | - main_sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND|wx.ALL, 5) | |
116 | + main_sizer.Add(fold_panel, 0, wx.GROW|wx.EXPAND|wx.ALL, 5) | |
113 | 117 | main_sizer.Add(button_next, 0, wx.ALIGN_RIGHT|wx.RIGHT|wx.BOTTOM, 5) |
114 | 118 | main_sizer.Fit(self) |
115 | 119 | |
116 | - self.SetSizer(main_sizer) | |
120 | + self.SetSizerAndFit(main_sizer) | |
117 | 121 | self.Update() |
118 | - self.SetAutoLayout(1) | |
122 | + #self.SetAutoLayout(1) | |
119 | 123 | |
120 | 124 | self.sizer = main_sizer |
121 | 125 | |
... | ... | @@ -132,7 +136,7 @@ class InnerTaskPanel(wx.Panel): |
132 | 136 | def OnLinkNewSurface(self, evt=None): |
133 | 137 | #import gui.dialogs as dlg |
134 | 138 | sl = slice_.Slice() |
135 | - dialog = dlg.SurfaceCreationDialog(None, -1, | |
139 | + dialog = dlg.SurfaceCreationDialog(None, -1, | |
136 | 140 | _('New surface'), |
137 | 141 | mask_edited=sl.current_mask.was_edited) |
138 | 142 | |
... | ... | @@ -176,15 +180,14 @@ class InnerTaskPanel(wx.Panel): |
176 | 180 | class FoldPanel(wx.Panel): |
177 | 181 | def __init__(self, parent): |
178 | 182 | wx.Panel.__init__(self, parent, size=(50,700)) |
179 | - self.SetBackgroundColour(wx.Colour(0,255,0)) | |
180 | 183 | |
181 | 184 | inner_panel = InnerFoldPanel(self) |
182 | 185 | |
183 | 186 | sizer = wx.BoxSizer(wx.VERTICAL) |
184 | - sizer.Add(inner_panel, 1, wx.EXPAND|wx.GROW, 2) | |
187 | + sizer.Add(inner_panel, 0, wx.EXPAND|wx.GROW, 2) | |
185 | 188 | sizer.Fit(self) |
186 | 189 | |
187 | - self.SetSizer(sizer) | |
190 | + self.SetSizerAndFit(sizer) | |
188 | 191 | self.Update() |
189 | 192 | self.SetAutoLayout(1) |
190 | 193 | |
... | ... | @@ -201,7 +204,7 @@ class InnerFoldPanel(wx.Panel): |
201 | 204 | # parent panel. Perhaps we need to insert the item into the sizer also... |
202 | 205 | # Study this. |
203 | 206 | fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition, |
204 | - (10, 140), 0,fpb.FPB_SINGLE_FOLD) | |
207 | + wx.DefaultSize, 0,fpb.FPB_SINGLE_FOLD) | |
205 | 208 | |
206 | 209 | # Fold panel style |
207 | 210 | style = fpb.CaptionBarStyle() |
... | ... | @@ -214,7 +217,6 @@ class InnerFoldPanel(wx.Panel): |
214 | 217 | fold_panel.ApplyCaptionStyle(item, style) |
215 | 218 | fold_panel.AddFoldPanelWindow(item, SurfaceProperties(item), Spacing= 0, |
216 | 219 | leftSpacing=0, rightSpacing=0) |
217 | - fold_panel.Expand(fold_panel.GetFoldPanel(0)) | |
218 | 220 | |
219 | 221 | # Fold 2 - Surface tools |
220 | 222 | item = fold_panel.AddFoldPanel(_("Advanced options"), collapsed=True) |
... | ... | @@ -226,6 +228,9 @@ class InnerFoldPanel(wx.Panel): |
226 | 228 | # leftSpacing=0, rightSpacing=0) |
227 | 229 | #fold_panel.Expand(fold_panel.GetFoldPanel(1)) |
228 | 230 | |
231 | + self.fold_panel = fold_panel | |
232 | + self.__bind_evt() | |
233 | + | |
229 | 234 | # Panel sizer to expand fold panel |
230 | 235 | sizer = wx.BoxSizer(wx.VERTICAL) |
231 | 236 | sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) |
... | ... | @@ -235,12 +240,29 @@ class InnerFoldPanel(wx.Panel): |
235 | 240 | self.Update() |
236 | 241 | self.SetAutoLayout(1) |
237 | 242 | |
243 | + | |
244 | + fold_panel.Expand(fold_panel.GetFoldPanel(1)) | |
245 | + self.ResizeFPB() | |
246 | + fold_panel.Expand(fold_panel.GetFoldPanel(0)) | |
247 | + | |
248 | + def __bind_evt(self): | |
249 | + self.fold_panel.Bind(fpb.EVT_CAPTIONBAR, self.OnFoldPressCaption) | |
250 | + | |
251 | + def OnFoldPressCaption(self, evt): | |
252 | + evt.Skip() | |
253 | + wx.CallAfter(self.ResizeFPB) | |
254 | + | |
255 | + def ResizeFPB(self): | |
256 | + sizeNeeded = self.fold_panel.GetPanelsLength(0, 0)[2] | |
257 | + self.fold_panel.SetMinSize((self.fold_panel.GetSize()[0], sizeNeeded )) | |
258 | + self.fold_panel.SetSize((self.fold_panel.GetSize()[0], sizeNeeded)) | |
259 | + | |
238 | 260 | BTN_LARGEST = wx.NewId() |
239 | 261 | BTN_SPLIT = wx.NewId() |
240 | 262 | BTN_SEEDS = wx.NewId() |
241 | 263 | class SurfaceTools(wx.Panel): |
242 | 264 | def __init__(self, parent): |
243 | - wx.Panel.__init__(self, parent, size=(50,400)) | |
265 | + wx.Panel.__init__(self, parent) | |
244 | 266 | default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) |
245 | 267 | self.SetBackgroundColour(default_colour) |
246 | 268 | |
... | ... | @@ -327,9 +349,8 @@ class SurfaceTools(wx.Panel): |
327 | 349 | main_sizer.Add(fixed_sizer, 0, wx.GROW|wx.EXPAND|wx.TOP, 5) |
328 | 350 | |
329 | 351 | # Update main sizer and panel layout |
330 | - self.SetSizer(main_sizer) | |
352 | + self.SetSizerAndFit(main_sizer) | |
331 | 353 | self.Update() |
332 | - self.SetAutoLayout(1) | |
333 | 354 | self.sizer = main_sizer |
334 | 355 | |
335 | 356 | def OnLinkLargest(self, evt): |
... | ... | @@ -375,7 +396,7 @@ class SurfaceTools(wx.Panel): |
375 | 396 | |
376 | 397 | class SurfaceProperties(wx.Panel): |
377 | 398 | def __init__(self, parent): |
378 | - wx.Panel.__init__(self, parent, size=(50,400)) | |
399 | + wx.Panel.__init__(self, parent) | |
379 | 400 | default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) |
380 | 401 | self.SetBackgroundColour(default_colour) |
381 | 402 | |
... | ... | @@ -384,7 +405,8 @@ class SurfaceProperties(wx.Panel): |
384 | 405 | ## LINE 1 |
385 | 406 | |
386 | 407 | # Combo related to mask naem |
387 | - combo_surface_name = wx.ComboBox(self, -1, "", choices= self.surface_dict.keys(), | |
408 | + combo_surface_name = wx.ComboBox(self, -1, "", choices= | |
409 | + self.surface_dict.keys() or ["", ], | |
388 | 410 | style=wx.CB_DROPDOWN|wx.CB_READONLY) |
389 | 411 | combo_surface_name.SetSelection(0) |
390 | 412 | if sys.platform != 'win32': |
... | ... | @@ -436,9 +458,9 @@ class SurfaceProperties(wx.Panel): |
436 | 458 | #sizer.Add(cb, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP|wx.BOTTOM, 5) |
437 | 459 | sizer.Fit(self) |
438 | 460 | |
439 | - self.SetSizer(sizer) | |
461 | + self.SetSizerAndFit(sizer) | |
440 | 462 | self.Update() |
441 | - self.SetAutoLayout(1) | |
463 | + #self.SetAutoLayout(1) | |
442 | 464 | |
443 | 465 | self.__bind_events() |
444 | 466 | |
... | ... | @@ -499,7 +521,7 @@ class SurfaceProperties(wx.Panel): |
499 | 521 | self.button_colour.SetColour(colour) |
500 | 522 | self.slider_transparency.SetValue(transparency) |
501 | 523 | self.combo_surface_name.SetSelection(index) |
502 | - Publisher.sendMessage('Update surface data', (index)) | |
524 | + Publisher.sendMessage('Update surface data', (index)) | |
503 | 525 | |
504 | 526 | def OnComboName(self, evt): |
505 | 527 | surface_name = evt.GetString() |
... | ... | @@ -527,13 +549,15 @@ class SurfaceProperties(wx.Panel): |
527 | 549 | class QualityAdjustment(wx.Panel): |
528 | 550 | def __init__(self, parent): |
529 | 551 | import constants as const |
530 | - wx.Panel.__init__(self, parent, size=(50,240)) | |
552 | + wx.Panel.__init__(self, parent) | |
531 | 553 | default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) |
532 | 554 | self.SetBackgroundColour(default_colour) |
533 | 555 | |
534 | 556 | # LINE 1 |
535 | 557 | |
536 | - combo_quality = wx.ComboBox(self, -1, "", choices=const.SURFACE_QUALITY.keys(), | |
558 | + combo_quality = wx.ComboBox(self, -1, "", | |
559 | + choices=const.SURFACE_QUALITY.keys() or | |
560 | + ["", ], | |
537 | 561 | style=wx.CB_DROPDOWN|wx.CB_READONLY) |
538 | 562 | combo_quality.SetSelection(3) |
539 | 563 | combo_quality.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ... | ... |
invesalius/invesalius.py
... | ... | @@ -30,8 +30,9 @@ if sys.platform == 'win32': |
30 | 30 | else: |
31 | 31 | if sys.platform != 'darwin': |
32 | 32 | import wxversion |
33 | - wxversion.ensureMinimal('2.8-unicode', optionsRequired=True) | |
34 | - wxversion.select('2.8-unicode', optionsRequired=True) | |
33 | + #wxversion.ensureMinimal('2.8-unicode', optionsRequired=True) | |
34 | + #wxversion.select('2.8-unicode', optionsRequired=True) | |
35 | + wxversion.ensureMinimal('3.0') | |
35 | 36 | |
36 | 37 | import wx |
37 | 38 | #from wx.lib.pubsub import setupv1 #new wx | ... | ... |