Commit 6261edc12497004c2a5d9004c1a171e28d2222a6
Committed by
GitHub
1 parent
a042b58e
Exists in
master
Create a module to keep invesalius path (#183)
* created a file to keep all the inv paths * frame and task_slice using inv_paths * task slice, surface, export and data_notebook using invesalius.inv_paths * clut_raycasting using inv_paths * using pathlib in frame * dicom reader using inv_paths * neuronavigation using inv_paths * session using inv_paths * dialogs using inv_paths
Showing
23 changed files
with
290 additions
and
252 deletions
Show diff stats
app.py
@@ -65,21 +65,9 @@ import invesalius.i18n as i18n | @@ -65,21 +65,9 @@ import invesalius.i18n as i18n | ||
65 | import invesalius.session as ses | 65 | import invesalius.session as ses |
66 | import invesalius.utils as utils | 66 | import invesalius.utils as utils |
67 | 67 | ||
68 | -FS_ENCODE = sys.getfilesystemencoding() | ||
69 | - | ||
70 | -if sys.platform == 'win32': | ||
71 | - from invesalius.expanduser import expand_user | ||
72 | - try: | ||
73 | - USER_DIR = expand_user() | ||
74 | - except: | ||
75 | - USER_DIR = utils.decode(os.path.expanduser('~'), FS_ENCODE) | ||
76 | -else: | ||
77 | - USER_DIR = utils.decode(os.path.expanduser('~'),FS_ENCODE) | 68 | +from invesalius import inv_paths |
78 | 69 | ||
79 | -USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius') | ||
80 | -USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets') | ||
81 | -USER_RAYCASTING_PRESETS_DIRECTORY = os.path.join(USER_PRESET_DIR, u'raycasting') | ||
82 | -USER_LOG_DIR = os.path.join(USER_INV_DIR, u'logs') | 70 | +FS_ENCODE = sys.getfilesystemencoding() |
83 | 71 | ||
84 | # ------------------------------------------------------------------ | 72 | # ------------------------------------------------------------------ |
85 | 73 | ||
@@ -510,17 +498,14 @@ if __name__ == '__main__': | @@ -510,17 +498,14 @@ if __name__ == '__main__': | ||
510 | 498 | ||
511 | os.chdir(path) | 499 | os.chdir(path) |
512 | 500 | ||
513 | - # Create raycasting presets' folder, if it doens't exist | ||
514 | - if not os.path.isdir(USER_RAYCASTING_PRESETS_DIRECTORY): | ||
515 | - os.makedirs(USER_RAYCASTING_PRESETS_DIRECTORY) | ||
516 | - | ||
517 | - # Create logs' folder, if it doesn't exist | ||
518 | - if not os.path.isdir(USER_LOG_DIR): | ||
519 | - os.makedirs(USER_LOG_DIR) | 501 | + if not inv_paths.USER_INV_DIR.exists(): |
502 | + inv_paths.create_conf_folders() | ||
503 | + if inv_paths.OLD_USER_INV_DIR.exists(): | ||
504 | + inv_paths.copy_old_files() | ||
520 | 505 | ||
521 | if hasattr(sys,"frozen") and sys.frozen == "windows_exe": | 506 | if hasattr(sys,"frozen") and sys.frozen == "windows_exe": |
522 | # Set system standard error output to file | 507 | # Set system standard error output to file |
523 | - path = os.path.join(USER_LOG_DIR, u"stderr.log") | 508 | + path = inv_paths.USER_LOG_DIR.join("stderr.log") |
524 | sys.stderr = open(path, "w") | 509 | sys.stderr = open(path, "w") |
525 | 510 | ||
526 | # Add current directory to PYTHONPATH, so other classes can | 511 | # Add current directory to PYTHONPATH, so other classes can |
invesalius/constants.py
@@ -24,6 +24,7 @@ import wx | @@ -24,6 +24,7 @@ import wx | ||
24 | import itertools | 24 | import itertools |
25 | 25 | ||
26 | from invesalius import utils | 26 | from invesalius import utils |
27 | +from invesalius import inv_paths | ||
27 | 28 | ||
28 | #from invesalius.project import Project | 29 | #from invesalius.project import Project |
29 | INVESALIUS_VERSION = "3.1.1" | 30 | INVESALIUS_VERSION = "3.1.1" |
@@ -335,59 +336,13 @@ REDUCE_IMAGEDATA_QUALITY = 0 | @@ -335,59 +336,13 @@ REDUCE_IMAGEDATA_QUALITY = 0 | ||
335 | # PATHS | 336 | # PATHS |
336 | FS_ENCODE = sys.getfilesystemencoding() | 337 | FS_ENCODE = sys.getfilesystemencoding() |
337 | 338 | ||
338 | -if sys.platform == 'win32': | ||
339 | - from invesalius.expanduser import expand_user | ||
340 | - try: | ||
341 | - USER_DIR = expand_user() | ||
342 | - except: | ||
343 | - USER_DIR = utils.decode(os.path.expanduser('~'), FS_ENCODE) | ||
344 | -else: | ||
345 | - USER_DIR = utils.decode(os.path.expanduser('~'), FS_ENCODE) | ||
346 | - | ||
347 | -USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius') | ||
348 | -USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets') | ||
349 | -USER_LOG_DIR = os.path.join(USER_INV_DIR, u'logs') | ||
350 | - | ||
351 | -FILE_PATH = utils.decode(os.path.split(__file__)[0], FS_ENCODE) | ||
352 | - | ||
353 | -if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ | ||
354 | - or sys.frozen == "console_exe"): | ||
355 | - abs_path = os.path.abspath(FILE_PATH, u'..', u'..', u'..') | ||
356 | - ICON_DIR = os.path.join(abs_path, u"icons") | ||
357 | - SAMPLE_DIR = os.path.join(FILE_PATH, u'samples') | ||
358 | - DOC_DIR = os.path.join(FILE_PATH, u'docs') | ||
359 | - folder=RAYCASTING_PRESETS_DIRECTORY= os.path.join(abs_path, u"presets", u"raycasting") | ||
360 | - RAYCASTING_PRESETS_COLOR_DIRECTORY = os.path.join(abs_path, u"presets", u"raycasting", u"color_list") | ||
361 | - | ||
362 | -else: | ||
363 | - ICON_DIR = os.path.abspath(os.path.join(FILE_PATH, u'..', u'icons')) | ||
364 | - SAMPLE_DIR = os.path.abspath(os.path.join(FILE_PATH, u'..', u'samples')) | ||
365 | - DOC_DIR = os.path.abspath(os.path.join(FILE_PATH, u'..', u'docs')) | ||
366 | - | ||
367 | - folder=RAYCASTING_PRESETS_DIRECTORY= os.path.abspath(os.path.join(u".", | ||
368 | - u"presets", | ||
369 | - u"raycasting")) | ||
370 | - | ||
371 | - RAYCASTING_PRESETS_COLOR_DIRECTORY = os.path.abspath(os.path.join(u".", | ||
372 | - u"presets", | ||
373 | - u"raycasting", | ||
374 | - u"color_list")) | ||
375 | - | ||
376 | - | ||
377 | -# MAC App | ||
378 | -if not os.path.exists(ICON_DIR): | ||
379 | - ICON_DIR = os.path.abspath(os.path.join(FILE_PATH, u'..', u'..', u'..', u'..', u'icons')) | ||
380 | - SAMPLE_DIR = os.path.abspath(os.path.join(FILE_PATH, u'..', u'..', u'..', u'..', u'samples')) | ||
381 | - DOC_DIR = os.path.abspath(os.path.join(FILE_PATH, u'..', u'..', u'..', u'..', u'docs')) | ||
382 | - | ||
383 | - | ||
384 | -ID_TO_BMP = {VOL_FRONT: [_("Front"), os.path.join(ICON_DIR, u"view_front.png")], | ||
385 | - VOL_BACK: [_("Back"), os.path.join(ICON_DIR, u"view_back.png")], | ||
386 | - VOL_TOP: [_("Top"), os.path.join(ICON_DIR, u"view_top.png")], | ||
387 | - VOL_BOTTOM: [_("Bottom"), os.path.join(ICON_DIR, u"view_bottom.png")], | ||
388 | - VOL_RIGHT: [_("Right"), os.path.join(ICON_DIR, u"view_right.png")], | ||
389 | - VOL_LEFT: [_("Left"), os.path.join(ICON_DIR, u"view_left.png")], | ||
390 | - VOL_ISO:[_("Isometric"), os.path.join(ICON_DIR, u"view_isometric.png")] | 339 | +ID_TO_BMP = {VOL_FRONT: [_("Front"), str(inv_paths.ICON_DIR.joinpath("view_front.png"))], |
340 | + VOL_BACK: [_("Back"), str(inv_paths.ICON_DIR.joinpath("view_back.png"))], | ||
341 | + VOL_TOP: [_("Top"), str(inv_paths.ICON_DIR.joinpath("view_top.png"))], | ||
342 | + VOL_BOTTOM: [_("Bottom"), str(inv_paths.ICON_DIR.joinpath("view_bottom.png"))], | ||
343 | + VOL_RIGHT: [_("Right"), str(inv_paths.ICON_DIR.joinpath("view_right.png"))], | ||
344 | + VOL_LEFT: [_("Left"), str(inv_paths.ICON_DIR.joinpath("view_left.png"))], | ||
345 | + VOL_ISO:[_("Isometric"), str(inv_paths.ICON_DIR.joinpath("view_isometric.png"))] | ||
391 | } | 346 | } |
392 | 347 | ||
393 | # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper | 348 | # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper |
@@ -433,10 +388,9 @@ RAYCASTING_FILES = {_("Airways"): "Airways.plist", | @@ -433,10 +388,9 @@ RAYCASTING_FILES = {_("Airways"): "Airways.plist", | ||
433 | # os.path.isfile(os.path.join(folder,filename))] | 388 | # os.path.isfile(os.path.join(folder,filename))] |
434 | 389 | ||
435 | 390 | ||
436 | -USER_RAYCASTING_PRESETS_DIRECTORY = os.path.join(USER_PRESET_DIR, u'raycasting') | ||
437 | -RAYCASTING_TYPES = [_(filename.split(".")[0]) for filename in | ||
438 | - os.listdir(USER_RAYCASTING_PRESETS_DIRECTORY) if | ||
439 | - os.path.isfile(os.path.join(USER_RAYCASTING_PRESETS_DIRECTORY, filename))] | 391 | +RAYCASTING_TYPES = [_(filename.name.split(".")[0]) for filename in |
392 | + inv_paths.USER_RAYCASTING_PRESETS_DIRECTORY.glob('*') if | ||
393 | + filename.is_file()] | ||
440 | RAYCASTING_TYPES += RAYCASTING_FILES.keys() | 394 | RAYCASTING_TYPES += RAYCASTING_FILES.keys() |
441 | RAYCASTING_TYPES.append(_(' Off')) | 395 | RAYCASTING_TYPES.append(_(' Off')) |
442 | RAYCASTING_TYPES.sort() | 396 | RAYCASTING_TYPES.sort() |
@@ -446,8 +400,8 @@ RAYCASTING_TOOLS = [_("Cut plane")] | @@ -446,8 +400,8 @@ RAYCASTING_TOOLS = [_("Cut plane")] | ||
446 | # If 0 dont't blur, 1 blur | 400 | # If 0 dont't blur, 1 blur |
447 | RAYCASTING_WWWL_BLUR = 0 | 401 | RAYCASTING_WWWL_BLUR = 0 |
448 | 402 | ||
449 | -RAYCASTING_PRESETS_FOLDERS = (RAYCASTING_PRESETS_DIRECTORY, | ||
450 | - USER_RAYCASTING_PRESETS_DIRECTORY) | 403 | +RAYCASTING_PRESETS_FOLDERS = (inv_paths.RAYCASTING_PRESETS_DIRECTORY, |
404 | + inv_paths.USER_RAYCASTING_PRESETS_DIRECTORY) | ||
451 | 405 | ||
452 | 406 | ||
453 | #### | 407 | #### |
@@ -761,14 +715,11 @@ TIPS_OBJ = [_("Select left object fiducial"), | @@ -761,14 +715,11 @@ TIPS_OBJ = [_("Select left object fiducial"), | ||
761 | _("Select object center"), | 715 | _("Select object center"), |
762 | _("Attach sensor to object")] | 716 | _("Attach sensor to object")] |
763 | 717 | ||
764 | -CAL_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'mtc_files', 'CalibrationFiles')) | ||
765 | -MAR_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'mtc_files', 'Markers')) | ||
766 | PROBE_NAME = "1Probe" | 718 | PROBE_NAME = "1Probe" |
767 | REF_NAME = "2Ref" | 719 | REF_NAME = "2Ref" |
768 | OBJ_NAME = "3Coil" | 720 | OBJ_NAME = "3Coil" |
769 | 721 | ||
770 | #OBJECT TRACKING | 722 | #OBJECT TRACKING |
771 | -OBJ_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'objects')) | ||
772 | ARROW_SCALE = 3 | 723 | ARROW_SCALE = 3 |
773 | ARROW_UPPER_LIMIT = 30 | 724 | ARROW_UPPER_LIMIT = 30 |
774 | #COIL_ANGLES_THRESHOLD = 3 * ARROW_SCALE | 725 | #COIL_ANGLES_THRESHOLD = 3 * ARROW_SCALE |
invesalius/control.py
@@ -42,6 +42,8 @@ import invesalius.gui.dialogs as dialogs | @@ -42,6 +42,8 @@ import invesalius.gui.dialogs as dialogs | ||
42 | import subprocess | 42 | import subprocess |
43 | import sys | 43 | import sys |
44 | 44 | ||
45 | +from invesalius import inv_paths | ||
46 | + | ||
45 | DEFAULT_THRESH_MODE = 0 | 47 | DEFAULT_THRESH_MODE = 0 |
46 | 48 | ||
47 | class Controller(): | 49 | class Controller(): |
@@ -920,13 +922,13 @@ class Controller(): | @@ -920,13 +922,13 @@ class Controller(): | ||
920 | def LoadRaycastingPreset(self, preset_name): | 922 | def LoadRaycastingPreset(self, preset_name): |
921 | if preset_name != const.RAYCASTING_OFF_LABEL: | 923 | if preset_name != const.RAYCASTING_OFF_LABEL: |
922 | if preset_name in const.RAYCASTING_FILES.keys(): | 924 | if preset_name in const.RAYCASTING_FILES.keys(): |
923 | - path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, | 925 | + path = os.path.join(inv_paths.RAYCASTING_PRESETS_DIRECTORY, |
924 | const.RAYCASTING_FILES[preset_name]) | 926 | const.RAYCASTING_FILES[preset_name]) |
925 | else: | 927 | else: |
926 | - path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, | 928 | + path = os.path.join(inv_paths.RAYCASTING_PRESETS_DIRECTORY, |
927 | preset_name+".plist") | 929 | preset_name+".plist") |
928 | if not os.path.isfile(path): | 930 | if not os.path.isfile(path): |
929 | - path = os.path.join(const.USER_RAYCASTING_PRESETS_DIRECTORY, | 931 | + path = os.path.join(inv_paths.USER_RAYCASTING_PRESETS_DIRECTORY, |
930 | preset_name+".plist") | 932 | preset_name+".plist") |
931 | preset = plistlib.readPlist(path) | 933 | preset = plistlib.readPlist(path) |
932 | prj.Project().raycasting_preset = preset | 934 | prj.Project().raycasting_preset = preset |
@@ -940,7 +942,7 @@ class Controller(): | @@ -940,7 +942,7 @@ class Controller(): | ||
940 | def SaveRaycastingPreset(self, preset_name): | 942 | def SaveRaycastingPreset(self, preset_name): |
941 | preset = prj.Project().raycasting_preset | 943 | preset = prj.Project().raycasting_preset |
942 | preset['name'] = preset_name | 944 | preset['name'] = preset_name |
943 | - preset_dir = os.path.join(const.USER_RAYCASTING_PRESETS_DIRECTORY, | 945 | + preset_dir = os.path.join(inv_paths.USER_RAYCASTING_PRESETS_DIRECTORY, |
944 | preset_name + '.plist') | 946 | preset_name + '.plist') |
945 | plistlib.writePlist(preset, preset_dir) | 947 | plistlib.writePlist(preset, preset_dir) |
946 | 948 |
invesalius/data/imagedata_utils.py
@@ -37,6 +37,8 @@ import invesalius.reader.bitmap_reader as bitmap_reader | @@ -37,6 +37,8 @@ import invesalius.reader.bitmap_reader as bitmap_reader | ||
37 | import invesalius.utils as utils | 37 | import invesalius.utils as utils |
38 | import invesalius.data.converters as converters | 38 | import invesalius.data.converters as converters |
39 | 39 | ||
40 | +from invesalius import inv_paths | ||
41 | + | ||
40 | if sys.platform == 'win32': | 42 | if sys.platform == 'win32': |
41 | try: | 43 | try: |
42 | import win32api | 44 | import win32api |
@@ -335,7 +337,7 @@ def CreateImageData(filelist, zspacing, xyspacing,size, | @@ -335,7 +337,7 @@ def CreateImageData(filelist, zspacing, xyspacing,size, | ||
335 | message = _("Generating multiplanar visualization...") | 337 | message = _("Generating multiplanar visualization...") |
336 | 338 | ||
337 | if not const.VTK_WARNING: | 339 | if not const.VTK_WARNING: |
338 | - log_path = os.path.join(const.USER_LOG_DIR, 'vtkoutput.txt') | 340 | + log_path = os.path.join(inv_paths.USER_LOG_DIR, 'vtkoutput.txt') |
339 | fow = vtk.vtkFileOutputWindow() | 341 | fow = vtk.vtkFileOutputWindow() |
340 | fow.SetFileName(log_path) | 342 | fow.SetFileName(log_path) |
341 | ow = vtk.vtkOutputWindow() | 343 | ow = vtk.vtkOutputWindow() |
@@ -440,7 +442,7 @@ class ImageCreator: | @@ -440,7 +442,7 @@ class ImageCreator: | ||
440 | message = _("Generating multiplanar visualization...") | 442 | message = _("Generating multiplanar visualization...") |
441 | 443 | ||
442 | if not const.VTK_WARNING: | 444 | if not const.VTK_WARNING: |
443 | - log_path = os.path.join(const.USER_LOG_DIR, 'vtkoutput.txt') | 445 | + log_path = os.path.join(inv_paths.USER_LOG_DIR, 'vtkoutput.txt') |
444 | fow = vtk.vtkFileOutputWindow() | 446 | fow = vtk.vtkFileOutputWindow() |
445 | fow.SetFileName(log_path) | 447 | fow.SetFileName(log_path) |
446 | ow = vtk.vtkOutputWindow() | 448 | ow = vtk.vtkOutputWindow() |
invesalius/data/trackers.py
@@ -61,6 +61,7 @@ def DefaultTracker(tracker_id): | @@ -61,6 +61,7 @@ def DefaultTracker(tracker_id): | ||
61 | 61 | ||
62 | def ClaronTracker(tracker_id): | 62 | def ClaronTracker(tracker_id): |
63 | import invesalius.constants as const | 63 | import invesalius.constants as const |
64 | + from invesalius import inv_paths | ||
64 | 65 | ||
65 | trck_init = None | 66 | trck_init = None |
66 | try: | 67 | try: |
@@ -68,8 +69,8 @@ def ClaronTracker(tracker_id): | @@ -68,8 +69,8 @@ def ClaronTracker(tracker_id): | ||
68 | 69 | ||
69 | lib_mode = 'wrapper' | 70 | lib_mode = 'wrapper' |
70 | trck_init = pyclaron.pyclaron() | 71 | trck_init = pyclaron.pyclaron() |
71 | - trck_init.CalibrationDir = const.CAL_DIR.encode(const.FS_ENCODE) | ||
72 | - trck_init.MarkerDir = const.MAR_DIR.encode(const.FS_ENCODE) | 72 | + trck_init.CalibrationDir = inv_paths.CAL_DIR.encode(const.FS_ENCODE) |
73 | + trck_init.MarkerDir = inv_paths.MAR_DIR.encode(const.FS_ENCODE) | ||
73 | trck_init.NumberFramesProcessed = 1 | 74 | trck_init.NumberFramesProcessed = 1 |
74 | trck_init.FramesExtrapolated = 0 | 75 | trck_init.FramesExtrapolated = 0 |
75 | trck_init.PROBE_NAME = const.PROBE_NAME.encode(const.FS_ENCODE) | 76 | trck_init.PROBE_NAME = const.PROBE_NAME.encode(const.FS_ENCODE) |
invesalius/data/viewer_volume.py
@@ -42,6 +42,8 @@ import invesalius.project as prj | @@ -42,6 +42,8 @@ import invesalius.project as prj | ||
42 | import invesalius.style as st | 42 | import invesalius.style as st |
43 | import invesalius.utils as utils | 43 | import invesalius.utils as utils |
44 | 44 | ||
45 | +from invesalius import inv_paths | ||
46 | + | ||
45 | if sys.platform == 'win32': | 47 | if sys.platform == 'win32': |
46 | try: | 48 | try: |
47 | import win32api | 49 | import win32api |
@@ -873,7 +875,7 @@ class Viewer(wx.Panel): | @@ -873,7 +875,7 @@ class Viewer(wx.Panel): | ||
873 | 875 | ||
874 | self.m_img_vtk = m_img_vtk | 876 | self.m_img_vtk = m_img_vtk |
875 | 877 | ||
876 | - filename = os.path.join(const.OBJ_DIR, "aim.stl") | 878 | + filename = os.path.join(inv_paths.OBJ_DIR, "aim.stl") |
877 | 879 | ||
878 | reader = vtk.vtkSTLReader() | 880 | reader = vtk.vtkSTLReader() |
879 | reader.SetFileName(filename) | 881 | reader.SetFileName(filename) |
@@ -898,7 +900,7 @@ class Viewer(wx.Panel): | @@ -898,7 +900,7 @@ class Viewer(wx.Panel): | ||
898 | self.aim_actor = aim_actor | 900 | self.aim_actor = aim_actor |
899 | self.ren.AddActor(aim_actor) | 901 | self.ren.AddActor(aim_actor) |
900 | 902 | ||
901 | - obj_polydata = self.CreateObjectPolyData(os.path.join(const.OBJ_DIR, "magstim_fig8_coil_no_handle.stl")) | 903 | + obj_polydata = self.CreateObjectPolyData(os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil_no_handle.stl")) |
902 | 904 | ||
903 | transform = vtk.vtkTransform() | 905 | transform = vtk.vtkTransform() |
904 | transform.RotateZ(90) | 906 | transform.RotateZ(90) |
@@ -1148,7 +1150,7 @@ class Viewer(wx.Panel): | @@ -1148,7 +1150,7 @@ class Viewer(wx.Panel): | ||
1148 | wx.MessageBox(_("File format not reconized by InVesalius"), _("Import surface error")) | 1150 | wx.MessageBox(_("File format not reconized by InVesalius"), _("Import surface error")) |
1149 | return | 1151 | return |
1150 | else: | 1152 | else: |
1151 | - filename = os.path.join(const.OBJ_DIR, "magstim_fig8_coil.stl") | 1153 | + filename = os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil.stl") |
1152 | reader = vtk.vtkSTLReader() | 1154 | reader = vtk.vtkSTLReader() |
1153 | 1155 | ||
1154 | if _has_win32api: | 1156 | if _has_win32api: |
invesalius/data/volume.py
@@ -33,6 +33,8 @@ import invesalius.data.vtk_utils as vtk_utils | @@ -33,6 +33,8 @@ import invesalius.data.vtk_utils as vtk_utils | ||
33 | from vtk.util import numpy_support | 33 | from vtk.util import numpy_support |
34 | import invesalius.session as ses | 34 | import invesalius.session as ses |
35 | 35 | ||
36 | +from invesalius import inv_paths | ||
37 | + | ||
36 | 38 | ||
37 | Kernels = { | 39 | Kernels = { |
38 | "Basic Smooth 5x5" : [1.0, 1.0, 1.0, 1.0, 1.0, | 40 | "Basic Smooth 5x5" : [1.0, 1.0, 1.0, 1.0, 1.0, |
@@ -352,7 +354,7 @@ class Volume(): | @@ -352,7 +354,7 @@ class Volume(): | ||
352 | color_preset = self.config['CLUT'] | 354 | color_preset = self.config['CLUT'] |
353 | if color_preset != "No CLUT": | 355 | if color_preset != "No CLUT": |
354 | p = plistlib.readPlist( | 356 | p = plistlib.readPlist( |
355 | - os.path.join(const.RAYCASTING_PRESETS_DIRECTORY, | 357 | + os.path.join(inv_paths.RAYCASTING_PRESETS_DIRECTORY, |
356 | 'color_list', color_preset + '.plist')) | 358 | 'color_list', color_preset + '.plist')) |
357 | r = p['Red'] | 359 | r = p['Red'] |
358 | g = p['Green'] | 360 | g = p['Green'] |
invesalius/gui/data_notebook.py
@@ -43,6 +43,8 @@ import invesalius.gui.dialogs as dlg | @@ -43,6 +43,8 @@ import invesalius.gui.dialogs as dlg | ||
43 | import wx.lib.mixins.listctrl as listmix | 43 | import wx.lib.mixins.listctrl as listmix |
44 | import invesalius.utils as ul | 44 | import invesalius.utils as ul |
45 | 45 | ||
46 | +from invesalius import inv_paths | ||
47 | + | ||
46 | 48 | ||
47 | BTN_NEW, BTN_REMOVE, BTN_DUPLICATE, BTN_OPEN = [wx.NewId() for i in range(4)] | 49 | BTN_NEW, BTN_REMOVE, BTN_DUPLICATE, BTN_OPEN = [wx.NewId() for i in range(4)] |
48 | 50 | ||
@@ -155,11 +157,11 @@ class MeasureButtonControlPanel(wx.Panel): | @@ -155,11 +157,11 @@ class MeasureButtonControlPanel(wx.Panel): | ||
155 | def __init_gui(self): | 157 | def __init_gui(self): |
156 | 158 | ||
157 | # Bitmaps to be used in plate buttons | 159 | # Bitmaps to be used in plate buttons |
158 | - BMP_NEW = wx.Bitmap(os.path.join(const.ICON_DIR, "data_new.png"), | 160 | + BMP_NEW = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "data_new.png"), |
159 | wx.BITMAP_TYPE_PNG) | 161 | wx.BITMAP_TYPE_PNG) |
160 | - BMP_REMOVE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_remove.png"), | 162 | + BMP_REMOVE = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "data_remove.png"), |
161 | wx.BITMAP_TYPE_PNG) | 163 | wx.BITMAP_TYPE_PNG) |
162 | - BMP_DUPLICATE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_duplicate.png"), | 164 | + BMP_DUPLICATE = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "data_duplicate.png"), |
163 | wx.BITMAP_TYPE_PNG) | 165 | wx.BITMAP_TYPE_PNG) |
164 | 166 | ||
165 | # Plate buttons based on previous bitmaps | 167 | # Plate buttons based on previous bitmaps |
@@ -273,11 +275,11 @@ class ButtonControlPanel(wx.Panel): | @@ -273,11 +275,11 @@ class ButtonControlPanel(wx.Panel): | ||
273 | def __init_gui(self): | 275 | def __init_gui(self): |
274 | 276 | ||
275 | # Bitmaps to be used in plate buttons | 277 | # Bitmaps to be used in plate buttons |
276 | - BMP_NEW = wx.Bitmap(os.path.join(const.ICON_DIR, "data_new.png"), | 278 | + BMP_NEW = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "data_new.png"), |
277 | wx.BITMAP_TYPE_PNG) | 279 | wx.BITMAP_TYPE_PNG) |
278 | - BMP_REMOVE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_remove.png"), | 280 | + BMP_REMOVE = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "data_remove.png"), |
279 | wx.BITMAP_TYPE_PNG) | 281 | wx.BITMAP_TYPE_PNG) |
280 | - BMP_DUPLICATE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_duplicate.png"), | 282 | + BMP_DUPLICATE = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "data_duplicate.png"), |
281 | wx.BITMAP_TYPE_PNG) | 283 | wx.BITMAP_TYPE_PNG) |
282 | 284 | ||
283 | # Plate buttons based on previous bitmaps | 285 | # Plate buttons based on previous bitmaps |
@@ -473,13 +475,13 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt | @@ -473,13 +475,13 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt | ||
473 | def __init_image_list(self): | 475 | def __init_image_list(self): |
474 | self.imagelist = wx.ImageList(16, 16) | 476 | self.imagelist = wx.ImageList(16, 16) |
475 | 477 | ||
476 | - image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) | 478 | + image = wx.Image(os.path.join(inv_paths.ICON_DIR, "object_invisible.jpg")) |
477 | bitmap = wx.Bitmap(image.Scale(16, 16)) | 479 | bitmap = wx.Bitmap(image.Scale(16, 16)) |
478 | bitmap.SetWidth(16) | 480 | bitmap.SetWidth(16) |
479 | bitmap.SetHeight(16) | 481 | bitmap.SetHeight(16) |
480 | img_null = self.imagelist.Add(bitmap) | 482 | img_null = self.imagelist.Add(bitmap) |
481 | 483 | ||
482 | - image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) | 484 | + image = wx.Image(os.path.join(inv_paths.ICON_DIR, "object_visible.jpg")) |
483 | bitmap = wx.Bitmap(image.Scale(16, 16)) | 485 | bitmap = wx.Bitmap(image.Scale(16, 16)) |
484 | bitmap.SetWidth(16) | 486 | bitmap.SetWidth(16) |
485 | bitmap.SetHeight(16) | 487 | bitmap.SetHeight(16) |
@@ -487,7 +489,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt | @@ -487,7 +489,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt | ||
487 | 489 | ||
488 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) | 490 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
489 | 491 | ||
490 | - self.image_gray = Image.open(os.path.join(const.ICON_DIR, "object_colour.jpg")) | 492 | + self.image_gray = Image.open(os.path.join(inv_paths.ICON_DIR, "object_colour.jpg")) |
491 | 493 | ||
492 | def OnBeginLabelEdit(self, evt): | 494 | def OnBeginLabelEdit(self, evt): |
493 | if evt.GetColumn() == 1: | 495 | if evt.GetColumn() == 1: |
@@ -616,13 +618,13 @@ class SurfaceButtonControlPanel(wx.Panel): | @@ -616,13 +618,13 @@ class SurfaceButtonControlPanel(wx.Panel): | ||
616 | def __init_gui(self): | 618 | def __init_gui(self): |
617 | 619 | ||
618 | # Bitmaps to be used in plate buttons | 620 | # Bitmaps to be used in plate buttons |
619 | - BMP_NEW = wx.Bitmap(os.path.join(const.ICON_DIR, "data_new.png"), | 621 | + BMP_NEW = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "data_new.png"), |
620 | wx.BITMAP_TYPE_PNG) | 622 | wx.BITMAP_TYPE_PNG) |
621 | - BMP_REMOVE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_remove.png"), | 623 | + BMP_REMOVE = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "data_remove.png"), |
622 | wx.BITMAP_TYPE_PNG) | 624 | wx.BITMAP_TYPE_PNG) |
623 | - BMP_DUPLICATE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_duplicate.png"), | 625 | + BMP_DUPLICATE = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "data_duplicate.png"), |
624 | wx.BITMAP_TYPE_PNG) | 626 | wx.BITMAP_TYPE_PNG) |
625 | - BMP_OPEN = wx.Bitmap(os.path.join(const.ICON_DIR, "load_mesh.png"), | 627 | + BMP_OPEN = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "load_mesh.png"), |
626 | wx.BITMAP_TYPE_PNG) | 628 | wx.BITMAP_TYPE_PNG) |
627 | 629 | ||
628 | # Plate buttons based on previous bitmaps | 630 | # Plate buttons based on previous bitmaps |
@@ -839,13 +841,13 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis | @@ -839,13 +841,13 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis | ||
839 | def __init_image_list(self): | 841 | def __init_image_list(self): |
840 | self.imagelist = wx.ImageList(16, 16) | 842 | self.imagelist = wx.ImageList(16, 16) |
841 | 843 | ||
842 | - image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) | 844 | + image = wx.Image(os.path.join(inv_paths.ICON_DIR, "object_invisible.jpg")) |
843 | bitmap = wx.Bitmap(image.Scale(16, 16)) | 845 | bitmap = wx.Bitmap(image.Scale(16, 16)) |
844 | bitmap.SetWidth(16) | 846 | bitmap.SetWidth(16) |
845 | bitmap.SetHeight(16) | 847 | bitmap.SetHeight(16) |
846 | img_null = self.imagelist.Add(bitmap) | 848 | img_null = self.imagelist.Add(bitmap) |
847 | 849 | ||
848 | - image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) | 850 | + image = wx.Image(os.path.join(inv_paths.ICON_DIR, "object_visible.jpg")) |
849 | bitmap = wx.Bitmap(image.Scale(16, 16)) | 851 | bitmap = wx.Bitmap(image.Scale(16, 16)) |
850 | bitmap.SetWidth(16) | 852 | bitmap.SetWidth(16) |
851 | bitmap.SetHeight(16) | 853 | bitmap.SetHeight(16) |
@@ -853,7 +855,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis | @@ -853,7 +855,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis | ||
853 | 855 | ||
854 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) | 856 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
855 | 857 | ||
856 | - self.image_gray = Image.open(os.path.join(const.ICON_DIR, "object_colour.jpg")) | 858 | + self.image_gray = Image.open(os.path.join(inv_paths.ICON_DIR, "object_colour.jpg")) |
857 | 859 | ||
858 | def OnBeginLabelEdit(self, evt): | 860 | def OnBeginLabelEdit(self, evt): |
859 | if evt.GetColumn() == 1: | 861 | if evt.GetColumn() == 1: |
@@ -1114,13 +1116,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis | @@ -1114,13 +1116,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis | ||
1114 | def __init_image_list(self): | 1116 | def __init_image_list(self): |
1115 | self.imagelist = wx.ImageList(16, 16) | 1117 | self.imagelist = wx.ImageList(16, 16) |
1116 | 1118 | ||
1117 | - image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) | 1119 | + image = wx.Image(os.path.join(inv_paths.ICON_DIR, "object_invisible.jpg")) |
1118 | bitmap = wx.Bitmap(image.Scale(16, 16)) | 1120 | bitmap = wx.Bitmap(image.Scale(16, 16)) |
1119 | bitmap.SetWidth(16) | 1121 | bitmap.SetWidth(16) |
1120 | bitmap.SetHeight(16) | 1122 | bitmap.SetHeight(16) |
1121 | img_null = self.imagelist.Add(bitmap) | 1123 | img_null = self.imagelist.Add(bitmap) |
1122 | 1124 | ||
1123 | - image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) | 1125 | + image = wx.Image(os.path.join(inv_paths.ICON_DIR, "object_visible.jpg")) |
1124 | bitmap = wx.Bitmap(image.Scale(16, 16)) | 1126 | bitmap = wx.Bitmap(image.Scale(16, 16)) |
1125 | bitmap.SetWidth(16) | 1127 | bitmap.SetWidth(16) |
1126 | bitmap.SetHeight(16) | 1128 | bitmap.SetHeight(16) |
@@ -1128,7 +1130,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis | @@ -1128,7 +1130,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis | ||
1128 | 1130 | ||
1129 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) | 1131 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
1130 | 1132 | ||
1131 | - self.image_gray = Image.open(os.path.join(const.ICON_DIR, "object_colour.jpg")) | 1133 | + self.image_gray = Image.open(os.path.join(inv_paths.ICON_DIR, "object_colour.jpg")) |
1132 | 1134 | ||
1133 | def OnBeginLabelEdit(self, evt): | 1135 | def OnBeginLabelEdit(self, evt): |
1134 | if evt.GetColumn() == 1: | 1136 | if evt.GetColumn() == 1: |
@@ -1309,19 +1311,19 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.Check | @@ -1309,19 +1311,19 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.Check | ||
1309 | def __init_image_list(self): | 1311 | def __init_image_list(self): |
1310 | self.imagelist = wx.ImageList(16, 16) | 1312 | self.imagelist = wx.ImageList(16, 16) |
1311 | 1313 | ||
1312 | - image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) | 1314 | + image = wx.Image(os.path.join(inv_paths.ICON_DIR, "object_visible.jpg")) |
1313 | bitmap = wx.Bitmap(image.Scale(16, 16)) | 1315 | bitmap = wx.Bitmap(image.Scale(16, 16)) |
1314 | bitmap.SetWidth(16) | 1316 | bitmap.SetWidth(16) |
1315 | bitmap.SetHeight(16) | 1317 | bitmap.SetHeight(16) |
1316 | img_check = self.imagelist.Add(bitmap) | 1318 | img_check = self.imagelist.Add(bitmap) |
1317 | 1319 | ||
1318 | - image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) | 1320 | + image = wx.Image(os.path.join(inv_paths.ICON_DIR, "object_invisible.jpg")) |
1319 | bitmap = wx.Bitmap(image.Scale(16, 16)) | 1321 | bitmap = wx.Bitmap(image.Scale(16, 16)) |
1320 | bitmap.SetWidth(16) | 1322 | bitmap.SetWidth(16) |
1321 | bitmap.SetHeight(16) | 1323 | bitmap.SetHeight(16) |
1322 | img_null = self.imagelist.Add(bitmap) | 1324 | img_null = self.imagelist.Add(bitmap) |
1323 | 1325 | ||
1324 | - image = wx.Image(os.path.join(const.ICON_DIR, "object_colour.jpg")) | 1326 | + image = wx.Image(os.path.join(inv_paths.ICON_DIR, "object_colour.jpg")) |
1325 | bitmap = wx.Bitmap(image.Scale(16, 16)) | 1327 | bitmap = wx.Bitmap(image.Scale(16, 16)) |
1326 | bitmap.SetWidth(16) | 1328 | bitmap.SetWidth(16) |
1327 | bitmap.SetHeight(16) | 1329 | bitmap.SetHeight(16) |
invesalius/gui/default_viewers.py
@@ -34,6 +34,7 @@ from invesalius.gui.widgets.clut_raycasting import CLUTRaycastingWidget, \ | @@ -34,6 +34,7 @@ from invesalius.gui.widgets.clut_raycasting import CLUTRaycastingWidget, \ | ||
34 | EVT_CLUT_CURVE_WL_CHANGE | 34 | EVT_CLUT_CURVE_WL_CHANGE |
35 | 35 | ||
36 | from invesalius.constants import ID_TO_BMP | 36 | from invesalius.constants import ID_TO_BMP |
37 | +from invesalius import inv_paths | ||
37 | 38 | ||
38 | import invesalius.session as ses | 39 | import invesalius.session as ses |
39 | import invesalius.constants as const | 40 | import invesalius.constants as const |
@@ -348,17 +349,17 @@ class VolumeToolPanel(wx.Panel): | @@ -348,17 +349,17 @@ class VolumeToolPanel(wx.Panel): | ||
348 | wx.Panel.__init__(self, parent) | 349 | wx.Panel.__init__(self, parent) |
349 | 350 | ||
350 | # VOLUME RAYCASTING BUTTON | 351 | # VOLUME RAYCASTING BUTTON |
351 | - BMP_RAYCASTING = wx.Bitmap(os.path.join(const.ICON_DIR, "volume_raycasting.png"), | 352 | + BMP_RAYCASTING = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "volume_raycasting.png"), |
352 | wx.BITMAP_TYPE_PNG) | 353 | wx.BITMAP_TYPE_PNG) |
353 | 354 | ||
354 | - BMP_SLICE_PLANE = wx.Bitmap(os.path.join(const.ICON_DIR, "slice_plane.png"), | 355 | + BMP_SLICE_PLANE = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "slice_plane.png"), |
355 | wx.BITMAP_TYPE_PNG) | 356 | wx.BITMAP_TYPE_PNG) |
356 | 357 | ||
357 | 358 | ||
358 | - BMP_3D_STEREO = wx.Bitmap(os.path.join(const.ICON_DIR, "3D_glasses.png"), | 359 | + BMP_3D_STEREO = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "3D_glasses.png"), |
359 | wx.BITMAP_TYPE_PNG) | 360 | wx.BITMAP_TYPE_PNG) |
360 | 361 | ||
361 | - BMP_TARGET = wx.Bitmap(os.path.join(const.ICON_DIR, "target.png"), | 362 | + BMP_TARGET = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "target.png"), |
362 | wx.BITMAP_TYPE_PNG) | 363 | wx.BITMAP_TYPE_PNG) |
363 | 364 | ||
364 | 365 |
invesalius/gui/dialogs.py
@@ -64,6 +64,8 @@ from invesalius.gui.widgets import clut_imagedata | @@ -64,6 +64,8 @@ from invesalius.gui.widgets import clut_imagedata | ||
64 | from invesalius.gui.widgets.clut_imagedata import CLUTImageDataWidget, EVT_CLUT_NODE_CHANGED | 64 | from invesalius.gui.widgets.clut_imagedata import CLUTImageDataWidget, EVT_CLUT_NODE_CHANGED |
65 | import numpy as np | 65 | import numpy as np |
66 | 66 | ||
67 | +from invesalius import inv_paths | ||
68 | + | ||
67 | try: | 69 | try: |
68 | from agw import floatspin as FS | 70 | from agw import floatspin as FS |
69 | except ImportError: # if it's not there locally, try the wxPython lib. | 71 | except ImportError: # if it's not there locally, try the wxPython lib. |
@@ -3443,10 +3445,10 @@ class ObjectCalibrationDialog(wx.Dialog): | @@ -3443,10 +3445,10 @@ class ObjectCalibrationDialog(wx.Dialog): | ||
3443 | wx.MessageBox(_("File format not reconized by InVesalius"), _("Import surface error")) | 3445 | wx.MessageBox(_("File format not reconized by InVesalius"), _("Import surface error")) |
3444 | return | 3446 | return |
3445 | else: | 3447 | else: |
3446 | - filename = os.path.join(const.OBJ_DIR, "magstim_fig8_coil.stl") | 3448 | + filename = os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil.stl") |
3447 | reader = vtk.vtkSTLReader() | 3449 | reader = vtk.vtkSTLReader() |
3448 | else: | 3450 | else: |
3449 | - filename = os.path.join(const.OBJ_DIR, "magstim_fig8_coil.stl") | 3451 | + filename = os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil.stl") |
3450 | reader = vtk.vtkSTLReader() | 3452 | reader = vtk.vtkSTLReader() |
3451 | 3453 | ||
3452 | if _has_win32api: | 3454 | if _has_win32api: |
invesalius/gui/frame.py
@@ -23,31 +23,31 @@ import platform | @@ -23,31 +23,31 @@ import platform | ||
23 | import sys | 23 | import sys |
24 | import webbrowser | 24 | import webbrowser |
25 | 25 | ||
26 | -import wx | ||
27 | - | ||
28 | -try: | ||
29 | - from wx.adv import TaskBarIcon as wx_TaskBarIcon | ||
30 | -except ImportError: | ||
31 | - from wx import TaskBarIcon as wx_TaskBarIcon | ||
32 | - | ||
33 | -import wx.aui | ||
34 | -from wx.lib.pubsub import pub as Publisher | ||
35 | -import wx.lib.agw.toasterbox as TB | ||
36 | -import wx.lib.popupctl as pc | ||
37 | - | ||
38 | -from wx.lib.agw.aui.auibar import AuiToolBar, AUI_TB_PLAIN_BACKGROUND | ||
39 | - | ||
40 | import invesalius.constants as const | 26 | import invesalius.constants as const |
41 | import invesalius.gui.default_tasks as tasks | 27 | import invesalius.gui.default_tasks as tasks |
42 | import invesalius.gui.default_viewers as viewers | 28 | import invesalius.gui.default_viewers as viewers |
43 | import invesalius.gui.dialogs as dlg | 29 | import invesalius.gui.dialogs as dlg |
44 | -import invesalius.gui.import_panel as imp | ||
45 | import invesalius.gui.import_bitmap_panel as imp_bmp | 30 | import invesalius.gui.import_bitmap_panel as imp_bmp |
31 | +import invesalius.gui.import_panel as imp | ||
32 | +import invesalius.gui.preferences as preferences | ||
46 | # import invesalius.gui.import_network_panel as imp_net | 33 | # import invesalius.gui.import_network_panel as imp_net |
47 | import invesalius.project as prj | 34 | import invesalius.project as prj |
48 | import invesalius.session as ses | 35 | import invesalius.session as ses |
49 | import invesalius.utils as utils | 36 | import invesalius.utils as utils |
50 | -import invesalius.gui.preferences as preferences | 37 | +import wx |
38 | +import wx.aui | ||
39 | +import wx.lib.agw.toasterbox as TB | ||
40 | +import wx.lib.popupctl as pc | ||
41 | +from invesalius import inv_paths | ||
42 | +from wx.lib.agw.aui.auibar import AUI_TB_PLAIN_BACKGROUND, AuiToolBar | ||
43 | +from wx.lib.pubsub import pub as Publisher | ||
44 | + | ||
45 | +try: | ||
46 | + from wx.adv import TaskBarIcon as wx_TaskBarIcon | ||
47 | +except ImportError: | ||
48 | + from wx import TaskBarIcon as wx_TaskBarIcon | ||
49 | + | ||
50 | + | ||
51 | # Layout tools' IDs - this is used only locally, therefore doesn't | 51 | # Layout tools' IDs - this is used only locally, therefore doesn't |
52 | # need to be defined in constants.py | 52 | # need to be defined in constants.py |
53 | VIEW_TOOLS = [ID_LAYOUT, ID_TEXT] =\ | 53 | VIEW_TOOLS = [ID_LAYOUT, ID_TEXT] =\ |
@@ -94,8 +94,8 @@ class Frame(wx.Frame): | @@ -94,8 +94,8 @@ class Frame(wx.Frame): | ||
94 | size=wx.Size(1024, 748), #size = wx.DisplaySize(), | 94 | size=wx.Size(1024, 748), #size = wx.DisplaySize(), |
95 | style=wx.DEFAULT_FRAME_STYLE, title='InVesalius 3') | 95 | style=wx.DEFAULT_FRAME_STYLE, title='InVesalius 3') |
96 | self.Center(wx.BOTH) | 96 | self.Center(wx.BOTH) |
97 | - icon_path = os.path.join(const.ICON_DIR, "invesalius.ico") | ||
98 | - self.SetIcon(wx.Icon(icon_path, wx.BITMAP_TYPE_ICO)) | 97 | + icon_path = inv_paths.ICON_DIR.joinpath("invesalius.ico") |
98 | + self.SetIcon(wx.Icon(str(icon_path), wx.BITMAP_TYPE_ICO)) | ||
99 | 99 | ||
100 | self.mw = None | 100 | self.mw = None |
101 | self._last_viewer_orientation_focus = const.AXIAL_STR | 101 | self._last_viewer_orientation_focus = const.AXIAL_STR |
@@ -621,7 +621,7 @@ class Frame(wx.Frame): | @@ -621,7 +621,7 @@ class Frame(wx.Frame): | ||
621 | else: | 621 | else: |
622 | user_guide = "user_guide_en.pdf" | 622 | user_guide = "user_guide_en.pdf" |
623 | 623 | ||
624 | - path = os.path.join(const.DOC_DIR, | 624 | + path = os.path.join(inv_paths.DOC_DIR, |
625 | user_guide) | 625 | user_guide) |
626 | if sys.platform == 'darwin': | 626 | if sys.platform == 'darwin': |
627 | path = r'file://' + path | 627 | path = r'file://' + path |
@@ -846,7 +846,7 @@ class MenuBar(wx.MenuBar): | @@ -846,7 +846,7 @@ class MenuBar(wx.MenuBar): | ||
846 | app(const.ID_EXIT, _("Exit\tCtrl+Q")) | 846 | app(const.ID_EXIT, _("Exit\tCtrl+Q")) |
847 | 847 | ||
848 | file_edit = wx.Menu() | 848 | file_edit = wx.Menu() |
849 | - d = const.ICON_DIR | 849 | + d = inv_paths.ICON_DIR |
850 | if not(sys.platform == 'darwin'): | 850 | if not(sys.platform == 'darwin'): |
851 | # Bitmaps for show/hide task panel item | 851 | # Bitmaps for show/hide task panel item |
852 | p = os.path.join(d, "undo_menu.png") | 852 | p = os.path.join(d, "undo_menu.png") |
@@ -1284,43 +1284,43 @@ class ProjectToolBar(AuiToolBar): | @@ -1284,43 +1284,43 @@ class ProjectToolBar(AuiToolBar): | ||
1284 | Add tools into toolbar. | 1284 | Add tools into toolbar. |
1285 | """ | 1285 | """ |
1286 | # Load bitmaps | 1286 | # Load bitmaps |
1287 | - d = const.ICON_DIR | 1287 | + d = inv_paths.ICON_DIR |
1288 | if sys.platform == 'darwin': | 1288 | if sys.platform == 'darwin': |
1289 | - path = os.path.join(d,"file_from_internet_original.png") | ||
1290 | - BMP_NET = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1289 | + path = d.joinpath("file_from_internet_original.png") |
1290 | + BMP_NET = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1291 | 1291 | ||
1292 | - path = os.path.join(d, "file_import_original.png") | ||
1293 | - BMP_IMPORT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1292 | + path = d.joinpath("file_import_original.png") |
1293 | + BMP_IMPORT = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1294 | 1294 | ||
1295 | - path = os.path.join(d, "file_open_original.png") | ||
1296 | - BMP_OPEN = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1295 | + path = d.joinpath("file_open_original.png") |
1296 | + BMP_OPEN = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1297 | 1297 | ||
1298 | - path = os.path.join(d, "file_save_original.png") | ||
1299 | - BMP_SAVE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1298 | + path = d.joinpath("file_save_original.png") |
1299 | + BMP_SAVE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1300 | 1300 | ||
1301 | - path = os.path.join(d, "print_original.png") | ||
1302 | - BMP_PRINT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1301 | + path = d.joinpath("print_original.png") |
1302 | + BMP_PRINT = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1303 | 1303 | ||
1304 | - path = os.path.join(d, "tool_photo_original.png") | ||
1305 | - BMP_PHOTO = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1304 | + path = d.joinpath("tool_photo_original.png") |
1305 | + BMP_PHOTO = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1306 | else: | 1306 | else: |
1307 | - path = os.path.join(d, "file_from_internet.png") | ||
1308 | - BMP_NET = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1307 | + path = d.joinpath("file_from_internet.png") |
1308 | + BMP_NET = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1309 | 1309 | ||
1310 | - path = os.path.join(d, "file_import.png") | ||
1311 | - BMP_IMPORT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1310 | + path = d.joinpath("file_import.png") |
1311 | + BMP_IMPORT = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1312 | 1312 | ||
1313 | - path = os.path.join(d, "file_open.png") | ||
1314 | - BMP_OPEN = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1313 | + path = d.joinpath("file_open.png") |
1314 | + BMP_OPEN = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1315 | 1315 | ||
1316 | - path = os.path.join(d, "file_save.png") | ||
1317 | - BMP_SAVE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1316 | + path = d.joinpath("file_save.png") |
1317 | + BMP_SAVE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1318 | 1318 | ||
1319 | - path = os.path.join(d, "print.png") | ||
1320 | - BMP_PRINT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1319 | + path = d.joinpath("print.png") |
1320 | + BMP_PRINT = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1321 | 1321 | ||
1322 | - path = os.path.join(d, "tool_photo.png") | ||
1323 | - BMP_PHOTO = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1322 | + path = d.joinpath("tool_photo.png") |
1323 | + BMP_PHOTO = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) | ||
1324 | 1324 | ||
1325 | # Create tool items based on bitmaps | 1325 | # Create tool items based on bitmaps |
1326 | self.AddTool(const.ID_DICOM_IMPORT, | 1326 | self.AddTool(const.ID_DICOM_IMPORT, |
@@ -1436,65 +1436,65 @@ class ObjectToolBar(AuiToolBar): | @@ -1436,65 +1436,65 @@ class ObjectToolBar(AuiToolBar): | ||
1436 | """ | 1436 | """ |
1437 | Add tools into toolbar. | 1437 | Add tools into toolbar. |
1438 | """ | 1438 | """ |
1439 | - d = const.ICON_DIR | 1439 | + d = inv_paths.ICON_DIR |
1440 | if sys.platform == 'darwin': | 1440 | if sys.platform == 'darwin': |
1441 | path = os.path.join(d, "tool_rotate_original.png") | 1441 | path = os.path.join(d, "tool_rotate_original.png") |
1442 | - BMP_ROTATE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1442 | + BMP_ROTATE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1443 | 1443 | ||
1444 | path = os.path.join(d, "tool_translate_original.png") | 1444 | path = os.path.join(d, "tool_translate_original.png") |
1445 | - BMP_MOVE =wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1445 | + BMP_MOVE =wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1446 | 1446 | ||
1447 | path = os.path.join(d, "tool_zoom_original.png") | 1447 | path = os.path.join(d, "tool_zoom_original.png") |
1448 | - BMP_ZOOM = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1448 | + BMP_ZOOM = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1449 | 1449 | ||
1450 | path = os.path.join(d, "tool_zoom_select_original.png") | 1450 | path = os.path.join(d, "tool_zoom_select_original.png") |
1451 | - BMP_ZOOM_SELECT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1451 | + BMP_ZOOM_SELECT = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1452 | 1452 | ||
1453 | path = os.path.join(d, "tool_contrast_original.png") | 1453 | path = os.path.join(d, "tool_contrast_original.png") |
1454 | - BMP_CONTRAST = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1454 | + BMP_CONTRAST = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1455 | 1455 | ||
1456 | path = os.path.join(d, "measure_line_original.png") | 1456 | path = os.path.join(d, "measure_line_original.png") |
1457 | - BMP_DISTANCE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1457 | + BMP_DISTANCE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1458 | 1458 | ||
1459 | path = os.path.join(d, "measure_angle_original.png") | 1459 | path = os.path.join(d, "measure_angle_original.png") |
1460 | - BMP_ANGLE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1460 | + BMP_ANGLE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1461 | 1461 | ||
1462 | path = os.path.join(d, "measure_density_ellipse32px.png") | 1462 | path = os.path.join(d, "measure_density_ellipse32px.png") |
1463 | - BMP_ELLIPSE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1463 | + BMP_ELLIPSE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1464 | 1464 | ||
1465 | path = os.path.join(d, "measure_density_polygon32px.png") | 1465 | path = os.path.join(d, "measure_density_polygon32px.png") |
1466 | - BMP_POLYGON = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1466 | + BMP_POLYGON = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1467 | 1467 | ||
1468 | #path = os.path.join(d, "tool_annotation_original.png") | 1468 | #path = os.path.join(d, "tool_annotation_original.png") |
1469 | #BMP_ANNOTATE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1469 | #BMP_ANNOTATE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) |
1470 | 1470 | ||
1471 | else: | 1471 | else: |
1472 | path = os.path.join(d, "tool_rotate.png") | 1472 | path = os.path.join(d, "tool_rotate.png") |
1473 | - BMP_ROTATE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1473 | + BMP_ROTATE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1474 | 1474 | ||
1475 | path = os.path.join(d, "tool_translate.png") | 1475 | path = os.path.join(d, "tool_translate.png") |
1476 | - BMP_MOVE =wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1476 | + BMP_MOVE =wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1477 | 1477 | ||
1478 | path = os.path.join(d, "tool_zoom.png") | 1478 | path = os.path.join(d, "tool_zoom.png") |
1479 | - BMP_ZOOM = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1479 | + BMP_ZOOM = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1480 | 1480 | ||
1481 | path = os.path.join(d, "tool_zoom_select.png") | 1481 | path = os.path.join(d, "tool_zoom_select.png") |
1482 | - BMP_ZOOM_SELECT = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1482 | + BMP_ZOOM_SELECT = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1483 | 1483 | ||
1484 | path = os.path.join(d, "tool_contrast.png") | 1484 | path = os.path.join(d, "tool_contrast.png") |
1485 | - BMP_CONTRAST = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1485 | + BMP_CONTRAST = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1486 | 1486 | ||
1487 | path = os.path.join(d, "measure_line.png") | 1487 | path = os.path.join(d, "measure_line.png") |
1488 | - BMP_DISTANCE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1488 | + BMP_DISTANCE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1489 | 1489 | ||
1490 | path = os.path.join(d, "measure_angle.png") | 1490 | path = os.path.join(d, "measure_angle.png") |
1491 | - BMP_ANGLE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1491 | + BMP_ANGLE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1492 | 1492 | ||
1493 | path = os.path.join(d, "measure_density_ellipse28px.png") | 1493 | path = os.path.join(d, "measure_density_ellipse28px.png") |
1494 | - BMP_ELLIPSE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1494 | + BMP_ELLIPSE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1495 | 1495 | ||
1496 | path = os.path.join(d, "measure_density_polygon28px.png") | 1496 | path = os.path.join(d, "measure_density_polygon28px.png") |
1497 | - BMP_POLYGON = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1497 | + BMP_POLYGON = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1498 | 1498 | ||
1499 | #path = os.path.join(d, "tool_annotation.png") | 1499 | #path = os.path.join(d, "tool_annotation.png") |
1500 | #BMP_ANNOTATE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1500 | #BMP_ANNOTATE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) |
@@ -1686,19 +1686,19 @@ class SliceToolBar(AuiToolBar): | @@ -1686,19 +1686,19 @@ class SliceToolBar(AuiToolBar): | ||
1686 | """ | 1686 | """ |
1687 | Add tools into toolbar. | 1687 | Add tools into toolbar. |
1688 | """ | 1688 | """ |
1689 | - d = const.ICON_DIR | 1689 | + d = inv_paths.ICON_DIR |
1690 | if sys.platform == 'darwin': | 1690 | if sys.platform == 'darwin': |
1691 | path = os.path.join(d, "slice_original.png") | 1691 | path = os.path.join(d, "slice_original.png") |
1692 | - BMP_SLICE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1692 | + BMP_SLICE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1693 | 1693 | ||
1694 | path = os.path.join(d,"cross_original.png") | 1694 | path = os.path.join(d,"cross_original.png") |
1695 | - BMP_CROSS = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1695 | + BMP_CROSS = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1696 | else: | 1696 | else: |
1697 | path = os.path.join(d, "slice.png") | 1697 | path = os.path.join(d, "slice.png") |
1698 | - BMP_SLICE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1698 | + BMP_SLICE = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1699 | 1699 | ||
1700 | path = os.path.join(d,"cross.png") | 1700 | path = os.path.join(d,"cross.png") |
1701 | - BMP_CROSS = wx.Bitmap(path, wx.BITMAP_TYPE_PNG) | 1701 | + BMP_CROSS = wx.Bitmap(str(path), wx.BITMAP_TYPE_PNG) |
1702 | 1702 | ||
1703 | self.sst = self.AddToggleTool(const.SLICE_STATE_SCROLL, | 1703 | self.sst = self.AddToggleTool(const.SLICE_STATE_SCROLL, |
1704 | BMP_SLICE,#, kind=wx.ITEM_CHECK) | 1704 | BMP_SLICE,#, kind=wx.ITEM_CHECK) |
@@ -1853,36 +1853,36 @@ class LayoutToolBar(AuiToolBar): | @@ -1853,36 +1853,36 @@ class LayoutToolBar(AuiToolBar): | ||
1853 | """ | 1853 | """ |
1854 | Add tools into toolbar. | 1854 | Add tools into toolbar. |
1855 | """ | 1855 | """ |
1856 | - d = const.ICON_DIR | 1856 | + d = inv_paths.ICON_DIR |
1857 | if sys.platform == 'darwin': | 1857 | if sys.platform == 'darwin': |
1858 | # Bitmaps for show/hide task panel item | 1858 | # Bitmaps for show/hide task panel item |
1859 | p = os.path.join(d, "layout_data_only_original.gif") | 1859 | p = os.path.join(d, "layout_data_only_original.gif") |
1860 | - self.BMP_WITH_MENU = wx.Bitmap(p, wx.BITMAP_TYPE_GIF) | 1860 | + self.BMP_WITH_MENU = wx.Bitmap(str(p), wx.BITMAP_TYPE_GIF) |
1861 | 1861 | ||
1862 | p = os.path.join(d, "layout_full_original.gif") | 1862 | p = os.path.join(d, "layout_full_original.gif") |
1863 | - self.BMP_WITHOUT_MENU = wx.Bitmap(p, wx.BITMAP_TYPE_GIF) | 1863 | + self.BMP_WITHOUT_MENU = wx.Bitmap(str(p), wx.BITMAP_TYPE_GIF) |
1864 | 1864 | ||
1865 | # Bitmaps for show/hide task item | 1865 | # Bitmaps for show/hide task item |
1866 | p = os.path.join(d, "text_inverted_original.png") | 1866 | p = os.path.join(d, "text_inverted_original.png") |
1867 | - self.BMP_WITHOUT_TEXT = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | 1867 | + self.BMP_WITHOUT_TEXT = wx.Bitmap(str(p), wx.BITMAP_TYPE_PNG) |
1868 | 1868 | ||
1869 | p = os.path.join(d, "text_original.png") | 1869 | p = os.path.join(d, "text_original.png") |
1870 | - self.BMP_WITH_TEXT = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | 1870 | + self.BMP_WITH_TEXT = wx.Bitmap(str(p), wx.BITMAP_TYPE_PNG) |
1871 | 1871 | ||
1872 | else: | 1872 | else: |
1873 | # Bitmaps for show/hide task panel item | 1873 | # Bitmaps for show/hide task panel item |
1874 | p = os.path.join(d, "layout_data_only.gif") | 1874 | p = os.path.join(d, "layout_data_only.gif") |
1875 | - self.BMP_WITH_MENU = wx.Bitmap(p, wx.BITMAP_TYPE_GIF) | 1875 | + self.BMP_WITH_MENU = wx.Bitmap(str(p), wx.BITMAP_TYPE_GIF) |
1876 | 1876 | ||
1877 | p = os.path.join(d, "layout_full.gif") | 1877 | p = os.path.join(d, "layout_full.gif") |
1878 | - self.BMP_WITHOUT_MENU = wx.Bitmap(p, wx.BITMAP_TYPE_GIF) | 1878 | + self.BMP_WITHOUT_MENU = wx.Bitmap(str(p), wx.BITMAP_TYPE_GIF) |
1879 | 1879 | ||
1880 | # Bitmaps for show/hide task item | 1880 | # Bitmaps for show/hide task item |
1881 | p = os.path.join(d, "text_inverted.png") | 1881 | p = os.path.join(d, "text_inverted.png") |
1882 | - self.BMP_WITHOUT_TEXT = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | 1882 | + self.BMP_WITHOUT_TEXT = wx.Bitmap(str(p), wx.BITMAP_TYPE_PNG) |
1883 | 1883 | ||
1884 | p = os.path.join(d, "text.png") | 1884 | p = os.path.join(d, "text.png") |
1885 | - self.BMP_WITH_TEXT = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | 1885 | + self.BMP_WITH_TEXT = wx.Bitmap(str(p), wx.BITMAP_TYPE_PNG) |
1886 | 1886 | ||
1887 | self.AddTool(ID_LAYOUT, | 1887 | self.AddTool(ID_LAYOUT, |
1888 | "", | 1888 | "", |
@@ -2035,22 +2035,22 @@ class HistoryToolBar(AuiToolBar): | @@ -2035,22 +2035,22 @@ class HistoryToolBar(AuiToolBar): | ||
2035 | """ | 2035 | """ |
2036 | Add tools into toolbar. | 2036 | Add tools into toolbar. |
2037 | """ | 2037 | """ |
2038 | - d = const.ICON_DIR | 2038 | + d = inv_paths.ICON_DIR |
2039 | if sys.platform == 'darwin': | 2039 | if sys.platform == 'darwin': |
2040 | # Bitmaps for show/hide task panel item | 2040 | # Bitmaps for show/hide task panel item |
2041 | p = os.path.join(d, "undo_original.png") | 2041 | p = os.path.join(d, "undo_original.png") |
2042 | - self.BMP_UNDO = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | 2042 | + self.BMP_UNDO = wx.Bitmap(str(p), wx.BITMAP_TYPE_PNG) |
2043 | 2043 | ||
2044 | p = os.path.join(d, "redo_original.png") | 2044 | p = os.path.join(d, "redo_original.png") |
2045 | - self.BMP_REDO = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | 2045 | + self.BMP_REDO = wx.Bitmap(str(p), wx.BITMAP_TYPE_PNG) |
2046 | 2046 | ||
2047 | else: | 2047 | else: |
2048 | # Bitmaps for show/hide task panel item | 2048 | # Bitmaps for show/hide task panel item |
2049 | p = os.path.join(d, "undo_small.png") | 2049 | p = os.path.join(d, "undo_small.png") |
2050 | - self.BMP_UNDO = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | 2050 | + self.BMP_UNDO = wx.Bitmap(str(p), wx.BITMAP_TYPE_PNG) |
2051 | 2051 | ||
2052 | p = os.path.join(d, "redo_small.png") | 2052 | p = os.path.join(d, "redo_small.png") |
2053 | - self.BMP_REDO = wx.Bitmap(p, wx.BITMAP_TYPE_PNG) | 2053 | + self.BMP_REDO = wx.Bitmap(str(p), wx.BITMAP_TYPE_PNG) |
2054 | 2054 | ||
2055 | self.AddTool(wx.ID_UNDO, | 2055 | self.AddTool(wx.ID_UNDO, |
2056 | "", | 2056 | "", |
invesalius/gui/task_exporter.py
@@ -35,6 +35,8 @@ import invesalius.gui.dialogs as dlg | @@ -35,6 +35,8 @@ import invesalius.gui.dialogs as dlg | ||
35 | import invesalius.project as proj | 35 | import invesalius.project as proj |
36 | import invesalius.session as ses | 36 | import invesalius.session as ses |
37 | 37 | ||
38 | +from invesalius import inv_paths | ||
39 | + | ||
38 | BTN_MASK = wx.NewId() | 40 | BTN_MASK = wx.NewId() |
39 | BTN_PICTURE = wx.NewId() | 41 | BTN_PICTURE = wx.NewId() |
40 | BTN_SURFACE = wx.NewId() | 42 | BTN_SURFACE = wx.NewId() |
@@ -170,22 +172,22 @@ class InnerTaskPanel(wx.Panel): | @@ -170,22 +172,22 @@ class InnerTaskPanel(wx.Panel): | ||
170 | # Image(s) for buttons | 172 | # Image(s) for buttons |
171 | if sys.platform == 'darwin': | 173 | if sys.platform == 'darwin': |
172 | BMP_EXPORT_SURFACE = wx.Bitmap(\ | 174 | BMP_EXPORT_SURFACE = wx.Bitmap(\ |
173 | - os.path.join(const.ICON_DIR, "surface_export_original.png"), | 175 | + os.path.join(inv_paths.ICON_DIR, "surface_export_original.png"), |
174 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ | 176 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ |
175 | .Rescale(25, 25).ConvertToBitmap() | 177 | .Rescale(25, 25).ConvertToBitmap() |
176 | BMP_TAKE_PICTURE = wx.Bitmap(\ | 178 | BMP_TAKE_PICTURE = wx.Bitmap(\ |
177 | - os.path.join(const.ICON_DIR, "tool_photo_original.png"), | 179 | + os.path.join(inv_paths.ICON_DIR, "tool_photo_original.png"), |
178 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ | 180 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ |
179 | .Rescale(25, 25).ConvertToBitmap() | 181 | .Rescale(25, 25).ConvertToBitmap() |
180 | 182 | ||
181 | #BMP_EXPORT_MASK = wx.Bitmap("../icons/mask.png", | 183 | #BMP_EXPORT_MASK = wx.Bitmap("../icons/mask.png", |
182 | # wx.BITMAP_TYPE_PNG) | 184 | # wx.BITMAP_TYPE_PNG) |
183 | else: | 185 | else: |
184 | - BMP_EXPORT_SURFACE = wx.Bitmap(os.path.join(const.ICON_DIR, "surface_export.png"), | 186 | + BMP_EXPORT_SURFACE = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "surface_export.png"), |
185 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ | 187 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ |
186 | .Rescale(25, 25).ConvertToBitmap() | 188 | .Rescale(25, 25).ConvertToBitmap() |
187 | 189 | ||
188 | - BMP_TAKE_PICTURE = wx.Bitmap(os.path.join(const.ICON_DIR, "tool_photo.png"), | 190 | + BMP_TAKE_PICTURE = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "tool_photo.png"), |
189 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ | 191 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ |
190 | .Rescale(25, 25).ConvertToBitmap() | 192 | .Rescale(25, 25).ConvertToBitmap() |
191 | 193 |
invesalius/gui/task_importer.py
@@ -31,6 +31,8 @@ from wx.lib.pubsub import pub as Publisher | @@ -31,6 +31,8 @@ from wx.lib.pubsub import pub as Publisher | ||
31 | import invesalius.constants as const | 31 | import invesalius.constants as const |
32 | import invesalius.gui.dialogs as dlg | 32 | import invesalius.gui.dialogs as dlg |
33 | 33 | ||
34 | +from invesalius import inv_paths | ||
35 | + | ||
34 | BTN_IMPORT_LOCAL = wx.NewId() | 36 | BTN_IMPORT_LOCAL = wx.NewId() |
35 | BTN_IMPORT_PACS = wx.NewId() | 37 | BTN_IMPORT_PACS = wx.NewId() |
36 | BTN_OPEN_PROJECT = wx.NewId() | 38 | BTN_OPEN_PROJECT = wx.NewId() |
@@ -100,9 +102,9 @@ class InnerTaskPanel(wx.Panel): | @@ -100,9 +102,9 @@ class InnerTaskPanel(wx.Panel): | ||
100 | link_open_proj.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkOpenProject) | 102 | link_open_proj.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkOpenProject) |
101 | 103 | ||
102 | # Image(s) for buttons | 104 | # Image(s) for buttons |
103 | - BMP_IMPORT = wx.Bitmap(os.path.join(const.ICON_DIR, "file_import.png"), wx.BITMAP_TYPE_PNG) | ||
104 | - BMP_NET = wx.Bitmap(os.path.join(const.ICON_DIR, "file_from_internet.png"), wx.BITMAP_TYPE_PNG) | ||
105 | - BMP_OPEN_PROJECT = wx.Bitmap(os.path.join(const.ICON_DIR, "file_open.png"), wx.BITMAP_TYPE_PNG) | 105 | + BMP_IMPORT = wx.Bitmap(str(inv_paths.ICON_DIR.joinpath("file_import.png")), wx.BITMAP_TYPE_PNG) |
106 | + BMP_NET = wx.Bitmap(str(inv_paths.ICON_DIR.joinpath("file_from_internet.png")), wx.BITMAP_TYPE_PNG) | ||
107 | + BMP_OPEN_PROJECT = wx.Bitmap(str(inv_paths.ICON_DIR.joinpath("file_open.png")), wx.BITMAP_TYPE_PNG) | ||
106 | 108 | ||
107 | bmp_list = [BMP_IMPORT, BMP_NET, BMP_OPEN_PROJECT] | 109 | bmp_list = [BMP_IMPORT, BMP_NET, BMP_OPEN_PROJECT] |
108 | #for bmp in bmp_list: | 110 | #for bmp in bmp_list: |
invesalius/gui/task_slice.py
@@ -40,6 +40,8 @@ import invesalius.gui.dialogs as dlg | @@ -40,6 +40,8 @@ import invesalius.gui.dialogs as dlg | ||
40 | import invesalius.gui.widgets.gradient as grad | 40 | import invesalius.gui.widgets.gradient as grad |
41 | from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl | 41 | from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl |
42 | 42 | ||
43 | +from invesalius import inv_paths | ||
44 | + | ||
43 | from invesalius.project import Project | 45 | from invesalius.project import Project |
44 | import invesalius.session as ses | 46 | import invesalius.session as ses |
45 | 47 | ||
@@ -78,7 +80,7 @@ class InnerTaskPanel(wx.Panel): | @@ -78,7 +80,7 @@ class InnerTaskPanel(wx.Panel): | ||
78 | self.SetAutoLayout(1) | 80 | self.SetAutoLayout(1) |
79 | 81 | ||
80 | # Image(s) for buttons | 82 | # Image(s) for buttons |
81 | - BMP_ADD = wx.Bitmap(os.path.join(const.ICON_DIR, "object_add.png"), wx.BITMAP_TYPE_PNG) | 83 | + BMP_ADD = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "object_add.png"), wx.BITMAP_TYPE_PNG) |
82 | #BMP_ADD.SetWidth(25) | 84 | #BMP_ADD.SetWidth(25) |
83 | #BMP_ADD.SetHeight(25) | 85 | #BMP_ADD.SetHeight(25) |
84 | 86 | ||
@@ -686,11 +688,11 @@ class EditionTools(wx.Panel): | @@ -686,11 +688,11 @@ class EditionTools(wx.Panel): | ||
686 | ## LINE 2 | 688 | ## LINE 2 |
687 | menu = wx.Menu() | 689 | menu = wx.Menu() |
688 | 690 | ||
689 | - CIRCLE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | 691 | + CIRCLE_BMP = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) |
690 | item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, _("Circle")) | 692 | item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, _("Circle")) |
691 | item.SetBitmap(CIRCLE_BMP) | 693 | item.SetBitmap(CIRCLE_BMP) |
692 | 694 | ||
693 | - SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) | 695 | + SQUARE_BMP = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) |
694 | item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square")) | 696 | item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square")) |
695 | item2.SetBitmap(SQUARE_BMP) | 697 | item2.SetBitmap(SQUARE_BMP) |
696 | 698 | ||
@@ -800,8 +802,8 @@ class EditionTools(wx.Panel): | @@ -800,8 +802,8 @@ class EditionTools(wx.Panel): | ||
800 | threshold_range=(thresh_min, thresh_max)) | 802 | threshold_range=(thresh_min, thresh_max)) |
801 | 803 | ||
802 | def OnMenu(self, evt): | 804 | def OnMenu(self, evt): |
803 | - SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) | ||
804 | - CIRCLE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | 805 | + SQUARE_BMP = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) |
806 | + CIRCLE_BMP = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | ||
805 | 807 | ||
806 | brush = {MENU_BRUSH_CIRCLE: const.BRUSH_CIRCLE, | 808 | brush = {MENU_BRUSH_CIRCLE: const.BRUSH_CIRCLE, |
807 | MENU_BRUSH_SQUARE: const.BRUSH_SQUARE} | 809 | MENU_BRUSH_SQUARE: const.BRUSH_SQUARE} |
@@ -849,11 +851,11 @@ class WatershedTool(EditionTools): | @@ -849,11 +851,11 @@ class WatershedTool(EditionTools): | ||
849 | ## LINE 2 | 851 | ## LINE 2 |
850 | menu = wx.Menu() | 852 | menu = wx.Menu() |
851 | 853 | ||
852 | - CIRCLE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | 854 | + CIRCLE_BMP = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) |
853 | item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, _("Circle")) | 855 | item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, _("Circle")) |
854 | item.SetBitmap(CIRCLE_BMP) | 856 | item.SetBitmap(CIRCLE_BMP) |
855 | 857 | ||
856 | - SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) | 858 | + SQUARE_BMP = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) |
857 | item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square")) | 859 | item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square")) |
858 | item2.SetBitmap(SQUARE_BMP) | 860 | item2.SetBitmap(SQUARE_BMP) |
859 | 861 | ||
@@ -903,7 +905,7 @@ class WatershedTool(EditionTools): | @@ -903,7 +905,7 @@ class WatershedTool(EditionTools): | ||
903 | self.ww_wl_cbox = ww_wl_cbox | 905 | self.ww_wl_cbox = ww_wl_cbox |
904 | 906 | ||
905 | # Line 6 | 907 | # Line 6 |
906 | - bmp = wx.Bitmap(os.path.join(const.ICON_DIR, "configuration.png"), wx.BITMAP_TYPE_PNG) | 908 | + bmp = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "configuration.png"), wx.BITMAP_TYPE_PNG) |
907 | self.btn_wconfig = wx.BitmapButton(self, -1, bitmap=bmp, | 909 | self.btn_wconfig = wx.BitmapButton(self, -1, bitmap=bmp, |
908 | size=(bmp.GetWidth()+10, bmp.GetHeight()+10)) | 910 | size=(bmp.GetWidth()+10, bmp.GetHeight()+10)) |
909 | self.btn_exp_watershed = wx.Button(self, -1, _('Expand watershed to 3D')) | 911 | self.btn_exp_watershed = wx.Button(self, -1, _('Expand watershed to 3D')) |
@@ -970,8 +972,8 @@ class WatershedTool(EditionTools): | @@ -970,8 +972,8 @@ class WatershedTool(EditionTools): | ||
970 | self.gradient_thresh.SetMaxValue(thresh_max) | 972 | self.gradient_thresh.SetMaxValue(thresh_max) |
971 | 973 | ||
972 | def OnMenu(self, evt): | 974 | def OnMenu(self, evt): |
973 | - SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) | ||
974 | - CIRCLE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | 975 | + SQUARE_BMP = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) |
976 | + CIRCLE_BMP = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | ||
975 | 977 | ||
976 | brush = {MENU_BRUSH_CIRCLE: const.BRUSH_CIRCLE, | 978 | brush = {MENU_BRUSH_CIRCLE: const.BRUSH_CIRCLE, |
977 | MENU_BRUSH_SQUARE: const.BRUSH_SQUARE} | 979 | MENU_BRUSH_SQUARE: const.BRUSH_SQUARE} |
invesalius/gui/task_surface.py
@@ -38,6 +38,7 @@ import wx.lib.platebtn as pbtn | @@ -38,6 +38,7 @@ import wx.lib.platebtn as pbtn | ||
38 | import invesalius.project as prj | 38 | import invesalius.project as prj |
39 | import invesalius.utils as utl | 39 | import invesalius.utils as utl |
40 | 40 | ||
41 | +from invesalius import inv_paths | ||
41 | from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl, InvFloatSpinCtrl | 42 | from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl, InvFloatSpinCtrl |
42 | 43 | ||
43 | #INTERPOLATION_MODE_LIST = ["Cubic", "Linear", "NearestNeighbor"] | 44 | #INTERPOLATION_MODE_LIST = ["Cubic", "Linear", "NearestNeighbor"] |
@@ -82,7 +83,7 @@ class InnerTaskPanel(wx.Panel): | @@ -82,7 +83,7 @@ class InnerTaskPanel(wx.Panel): | ||
82 | self.SetAutoLayout(1) | 83 | self.SetAutoLayout(1) |
83 | 84 | ||
84 | 85 | ||
85 | - BMP_ADD = wx.Bitmap(os.path.join(const.ICON_DIR, "object_add.png"), wx.BITMAP_TYPE_PNG) | 86 | + BMP_ADD = wx.Bitmap(os.path.join(inv_paths.ICON_DIR, "object_add.png"), wx.BITMAP_TYPE_PNG) |
86 | #BMP_ADD.SetWidth(25) | 87 | #BMP_ADD.SetWidth(25) |
87 | #BMP_ADD.SetHeight(25) | 88 | #BMP_ADD.SetHeight(25) |
88 | 89 | ||
@@ -330,17 +331,17 @@ class SurfaceTools(wx.Panel): | @@ -330,17 +331,17 @@ class SurfaceTools(wx.Panel): | ||
330 | link_seeds.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkSeed) | 331 | link_seeds.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkSeed) |
331 | 332 | ||
332 | # Image(s) for buttons | 333 | # Image(s) for buttons |
333 | - img_largest = wx.Image(os.path.join(const.ICON_DIR, "connectivity_largest.png"), | 334 | + img_largest = wx.Image(os.path.join(inv_paths.ICON_DIR, "connectivity_largest.png"), |
334 | wx.BITMAP_TYPE_PNG) | 335 | wx.BITMAP_TYPE_PNG) |
335 | img_largest.Rescale(25, 25) | 336 | img_largest.Rescale(25, 25) |
336 | bmp_largest = img_largest.ConvertToBitmap() | 337 | bmp_largest = img_largest.ConvertToBitmap() |
337 | 338 | ||
338 | - img_split_all = wx.Image(os.path.join(const.ICON_DIR, "connectivity_split_all.png"), | 339 | + img_split_all = wx.Image(os.path.join(inv_paths.ICON_DIR, "connectivity_split_all.png"), |
339 | wx.BITMAP_TYPE_PNG) | 340 | wx.BITMAP_TYPE_PNG) |
340 | img_split_all.Rescale(25, 25) | 341 | img_split_all.Rescale(25, 25) |
341 | bmp_split_all = img_split_all.ConvertToBitmap() | 342 | bmp_split_all = img_split_all.ConvertToBitmap() |
342 | 343 | ||
343 | - img_seeds = wx.Image(os.path.join(const.ICON_DIR, "connectivity_manual.png"), | 344 | + img_seeds = wx.Image(os.path.join(inv_paths.ICON_DIR, "connectivity_manual.png"), |
344 | wx.BITMAP_TYPE_PNG) | 345 | wx.BITMAP_TYPE_PNG) |
345 | img_seeds.Rescale(25, 25) | 346 | img_seeds.Rescale(25, 25) |
346 | bmp_seeds = img_seeds.ConvertToBitmap() | 347 | bmp_seeds = img_seeds.ConvertToBitmap() |
invesalius/gui/widgets/clut_raycasting.py
@@ -29,6 +29,8 @@ from wx.lib.pubsub import pub as Publisher | @@ -29,6 +29,8 @@ from wx.lib.pubsub import pub as Publisher | ||
29 | import invesalius.gui.dialogs as dialog | 29 | import invesalius.gui.dialogs as dialog |
30 | import invesalius.constants as const | 30 | import invesalius.constants as const |
31 | 31 | ||
32 | +from invesalius import inv_paths | ||
33 | + | ||
32 | FONT_COLOUR = (1, 1, 1) | 34 | FONT_COLOUR = (1, 1, 1) |
33 | LINE_COLOUR = (128, 128, 128) | 35 | LINE_COLOUR = (128, 128, 128) |
34 | LINE_WIDTH = 2 | 36 | LINE_WIDTH = 2 |
@@ -634,7 +636,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -634,7 +636,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
634 | self.Histogram.points.append((x, y)) | 636 | self.Histogram.points.append((x, y)) |
635 | 637 | ||
636 | def _build_buttons(self): | 638 | def _build_buttons(self): |
637 | - img = wx.Image(os.path.join(const.ICON_DIR, 'Floppy.png')) | 639 | + img = wx.Image(os.path.join(inv_paths.ICON_DIR, 'Floppy.png')) |
638 | width = img.GetWidth() | 640 | width = img.GetWidth() |
639 | height = img.GetHeight() | 641 | height = img.GetHeight() |
640 | self.save_button = Button() | 642 | self.save_button = Button() |
@@ -0,0 +1,79 @@ | @@ -0,0 +1,79 @@ | ||
1 | +import os | ||
2 | +import pathlib | ||
3 | +import shutil | ||
4 | +import sys | ||
5 | + | ||
6 | +USER_DIR = pathlib.Path().home() | ||
7 | +CONF_DIR = pathlib.Path(os.environ.get("XDG_CONFIG_HOME", USER_DIR.joinpath(".config"))) | ||
8 | +USER_INV_DIR = CONF_DIR.joinpath("invesalius") | ||
9 | +USER_PRESET_DIR = USER_INV_DIR.joinpath("presets") | ||
10 | +USER_LOG_DIR = USER_INV_DIR.joinpath("logs") | ||
11 | +USER_RAYCASTING_PRESETS_DIRECTORY = USER_PRESET_DIR.joinpath("raycasting") | ||
12 | + | ||
13 | +OLD_USER_INV_DIR = USER_DIR.joinpath(".invesalius") | ||
14 | +OLD_USER_PRESET_DIR = OLD_USER_INV_DIR.joinpath("presets") | ||
15 | +OLD_USER_LOG_DIR = OLD_USER_INV_DIR.joinpath("logs") | ||
16 | + | ||
17 | +INV_TOP_DIR = pathlib.Path(__file__).parent.parent.resolve() | ||
18 | + | ||
19 | +ICON_DIR = INV_TOP_DIR.joinpath("icons") | ||
20 | +SAMPLE_DIR = INV_TOP_DIR.joinpath("samples") | ||
21 | +DOC_DIR = INV_TOP_DIR.joinpath("docs") | ||
22 | +RAYCASTING_PRESETS_DIRECTORY = INV_TOP_DIR.joinpath("presets", "raycasting") | ||
23 | +RAYCASTING_PRESETS_COLOR_DIRECTORY = INV_TOP_DIR.joinpath( | ||
24 | + "presets", "raycasting", "color_list" | ||
25 | +) | ||
26 | + | ||
27 | +# Inside the windows executable | ||
28 | +if hasattr(sys, "frozen") and ( | ||
29 | + sys.frozen == "windows_exe" or sys.frozen == "console_exe" | ||
30 | +): | ||
31 | + abs_path = INV_TOP_DIR.parent.resolve() | ||
32 | + ICON_DIR = abs_path.joinpath("icons") | ||
33 | + SAMPLE_DIR = INV_TOP_DIR.joinpath("samples") | ||
34 | + DOC_DIR = INV_TOP_DIR.joinpath("docs") | ||
35 | + RAYCASTING_PRESETS_DIRECTORY = abs_path.joinpath("presets", "raycasting") | ||
36 | + RAYCASTING_PRESETS_COLOR_DIRECTORY = abs_path.joinpath( | ||
37 | + "presets", "raycasting", "color_list" | ||
38 | + ) | ||
39 | +else: | ||
40 | + | ||
41 | + ICON_DIR = pathlib.Path(os.environ.get("INV_ICON_DIR", ICON_DIR)) | ||
42 | + SAMPLE_DIR = pathlib.Path(os.environ.get("INV_SAMPLE_DIR", SAMPLE_DIR)) | ||
43 | + DOC_DIR = pathlib.Path(os.environ.get("INV_DOC_DIR", DOC_DIR)) | ||
44 | + RAYCASTING_PRESETS_DIRECTORY = pathlib.Path( | ||
45 | + os.environ.get("INV_RAYCASTING_PRESETS_DIR", RAYCASTING_PRESETS_DIRECTORY) | ||
46 | + ) | ||
47 | + RAYCASTING_PRESETS_COLOR_DIRECTORY = pathlib.Path( | ||
48 | + os.environ.get("INV_RAYCASTING_COLOR_DIR", RAYCASTING_PRESETS_COLOR_DIRECTORY) | ||
49 | + ) | ||
50 | + | ||
51 | +# Navigation paths | ||
52 | +CAL_DIR = INV_TOP_DIR.joinpath("navigation", "mtc_files", "CalibrationFiles") | ||
53 | +MAR_DIR = INV_TOP_DIR.joinpath("navigation", "mtc_files", "Markers") | ||
54 | +OBJ_DIR = INV_TOP_DIR.joinpath("navigation", "objects") | ||
55 | + | ||
56 | +# MAC App | ||
57 | +if not os.path.exists(ICON_DIR): | ||
58 | + ICON_DIR = INV_TOP_DIR.parent.parent.joinpath("icons").resolve() | ||
59 | + SAMPLE_DIR = INV_TOP_DIR.parent.parent.joinpath("samples").resolve() | ||
60 | + DOC_DIR = INV_TOP_DIR.parent.parent.joinpath("docs").resolve() | ||
61 | + | ||
62 | + | ||
63 | +def create_conf_folders(): | ||
64 | + USER_INV_DIR.mkdir(parents=True, exist_ok=True) | ||
65 | + USER_PRESET_DIR.mkdir(parents=True, exist_ok=True) | ||
66 | + USER_LOG_DIR.mkdir(parents=True, exist_ok=True) | ||
67 | + | ||
68 | + | ||
69 | +def copy_old_files(): | ||
70 | + for f in OLD_USER_INV_DIR.glob("*"): | ||
71 | + if f.is_file(): | ||
72 | + print( | ||
73 | + shutil.copy( | ||
74 | + f, | ||
75 | + USER_INV_DIR.joinpath( | ||
76 | + str(f).replace(str(OLD_USER_INV_DIR) + "/", "") | ||
77 | + ), | ||
78 | + ) | ||
79 | + ) |
invesalius/presets.py
@@ -24,7 +24,10 @@ import invesalius.constants as const | @@ -24,7 +24,10 @@ import invesalius.constants as const | ||
24 | 24 | ||
25 | from wx.lib.pubsub import pub as Publisher | 25 | from wx.lib.pubsub import pub as Publisher |
26 | 26 | ||
27 | +from invesalius import inv_paths | ||
27 | from invesalius.utils import TwoWaysDictionary | 28 | from invesalius.utils import TwoWaysDictionary |
29 | + | ||
30 | + | ||
28 | class Presets(): | 31 | class Presets(): |
29 | 32 | ||
30 | def __init__(self): | 33 | def __init__(self): |
@@ -169,7 +172,7 @@ class Presets(): | @@ -169,7 +172,7 @@ class Presets(): | ||
169 | 172 | ||
170 | 173 | ||
171 | def get_wwwl_presets(): | 174 | def get_wwwl_presets(): |
172 | - files = glob.glob(os.path.join(const.RAYCASTING_PRESETS_COLOR_DIRECTORY, '*.plist')) | 175 | + files = glob.glob(os.path.join(inv_paths.RAYCASTING_PRESETS_COLOR_DIRECTORY, '*.plist')) |
173 | presets = {} | 176 | presets = {} |
174 | for f in files: | 177 | for f in files: |
175 | p = os.path.splitext(os.path.basename(f))[0] | 178 | p = os.path.splitext(os.path.basename(f))[0] |
invesalius/project.py
@@ -39,6 +39,8 @@ from invesalius.presets import Presets | @@ -39,6 +39,8 @@ from invesalius.presets import Presets | ||
39 | from invesalius.utils import Singleton, debug, touch, decode | 39 | from invesalius.utils import Singleton, debug, touch, decode |
40 | import invesalius.version as version | 40 | import invesalius.version as version |
41 | 41 | ||
42 | +from invesalius import inv_paths | ||
43 | + | ||
42 | if sys.platform == 'win32': | 44 | if sys.platform == 'win32': |
43 | try: | 45 | try: |
44 | import win32api | 46 | import win32api |
@@ -280,7 +282,7 @@ class Project(with_metaclass(Singleton, object)): | @@ -280,7 +282,7 @@ class Project(with_metaclass(Singleton, object)): | ||
280 | import invesalius.data.surface as srf | 282 | import invesalius.data.surface as srf |
281 | 283 | ||
282 | if not const.VTK_WARNING: | 284 | if not const.VTK_WARNING: |
283 | - log_path = os.path.join(const.USER_LOG_DIR, 'vtkoutput.txt') | 285 | + log_path = os.path.join(inv_paths.USER_LOG_DIR, 'vtkoutput.txt') |
284 | fow = vtk.vtkFileOutputWindow() | 286 | fow = vtk.vtkFileOutputWindow() |
285 | fow.SetFileName(log_path.encode(const.FS_ENCODE)) | 287 | fow.SetFileName(log_path.encode(const.FS_ENCODE)) |
286 | ow = vtk.vtkOutputWindow() | 288 | ow = vtk.vtkOutputWindow() |
invesalius/reader/bitmap_reader.py
@@ -35,6 +35,9 @@ import imghdr | @@ -35,6 +35,9 @@ import imghdr | ||
35 | 35 | ||
36 | import invesalius.utils as utils | 36 | import invesalius.utils as utils |
37 | import invesalius.data.converters as converters | 37 | import invesalius.data.converters as converters |
38 | +from invesalius import inv_paths | ||
39 | + | ||
40 | + | ||
38 | #flag to control vtk error in read files | 41 | #flag to control vtk error in read files |
39 | no_error = True | 42 | no_error = True |
40 | vtk_error = False | 43 | vtk_error = False |
@@ -299,7 +302,7 @@ def ScipyRead(filepath): | @@ -299,7 +302,7 @@ def ScipyRead(filepath): | ||
299 | 302 | ||
300 | def VtkRead(filepath, t): | 303 | def VtkRead(filepath, t): |
301 | if not const.VTK_WARNING: | 304 | if not const.VTK_WARNING: |
302 | - log_path = os.path.join(const.USER_LOG_DIR, 'vtkoutput.txt') | 305 | + log_path = os.path.join(inv_paths.USER_LOG_DIR, 'vtkoutput.txt') |
303 | fow = vtk.vtkFileOutputWindow() | 306 | fow = vtk.vtkFileOutputWindow() |
304 | fow.SetFileName(log_path.encode(const.FS_ENCODE)) | 307 | fow.SetFileName(log_path.encode(const.FS_ENCODE)) |
305 | ow = vtk.vtkOutputWindow() | 308 | ow = vtk.vtkOutputWindow() |
invesalius/reader/dicom_reader.py
@@ -35,6 +35,7 @@ import invesalius.session as session | @@ -35,6 +35,7 @@ import invesalius.session as session | ||
35 | import glob | 35 | import glob |
36 | import invesalius.utils as utils | 36 | import invesalius.utils as utils |
37 | 37 | ||
38 | +from invesalius import inv_paths | ||
38 | from invesalius.data import imagedata_utils | 39 | from invesalius.data import imagedata_utils |
39 | 40 | ||
40 | import plistlib | 41 | import plistlib |
@@ -334,7 +335,7 @@ class ProgressDicomReader: | @@ -334,7 +335,7 @@ class ProgressDicomReader: | ||
334 | def GetDicomGroups(self, path, recursive): | 335 | def GetDicomGroups(self, path, recursive): |
335 | 336 | ||
336 | if not const.VTK_WARNING: | 337 | if not const.VTK_WARNING: |
337 | - log_path = utils.encode(os.path.join(const.USER_LOG_DIR, 'vtkoutput.txt'), const.FS_ENCODE) | 338 | + log_path = utils.encode(str(inv_paths.USER_LOG_DIR.joinpath('vtkoutput.txt')), const.FS_ENCODE) |
338 | fow = vtk.vtkFileOutputWindow() | 339 | fow = vtk.vtkFileOutputWindow() |
339 | fow.SetFileName(log_path) | 340 | fow.SetFileName(log_path) |
340 | ow = vtk.vtkOutputWindow() | 341 | ow = vtk.vtkOutputWindow() |
invesalius/reader/others_reader.py
@@ -23,6 +23,7 @@ import vtk | @@ -23,6 +23,7 @@ import vtk | ||
23 | import nibabel as nib | 23 | import nibabel as nib |
24 | 24 | ||
25 | import invesalius.constants as const | 25 | import invesalius.constants as const |
26 | +from invesalius import inv_paths | ||
26 | 27 | ||
27 | 28 | ||
28 | def ReadOthers(dir_): | 29 | def ReadOthers(dir_): |
@@ -38,7 +39,7 @@ def ReadOthers(dir_): | @@ -38,7 +39,7 @@ def ReadOthers(dir_): | ||
38 | """ | 39 | """ |
39 | 40 | ||
40 | if not const.VTK_WARNING: | 41 | if not const.VTK_WARNING: |
41 | - log_path = os.path.join(const.USER_LOG_DIR, 'vtkoutput.txt') | 42 | + log_path = os.path.join(inv_paths.USER_LOG_DIR, 'vtkoutput.txt') |
42 | fow = vtk.vtkFileOutputWindow() | 43 | fow = vtk.vtkFileOutputWindow() |
43 | fow.SetFileName(log_path.encode(const.FS_ENCODE)) | 44 | fow.SetFileName(log_path.encode(const.FS_ENCODE)) |
44 | ow = vtk.vtkOutputWindow() | 45 | ow = vtk.vtkOutputWindow() |
invesalius/session.py
@@ -40,22 +40,12 @@ import wx | @@ -40,22 +40,12 @@ import wx | ||
40 | from invesalius.utils import Singleton, debug, decode | 40 | from invesalius.utils import Singleton, debug, decode |
41 | from random import randint | 41 | from random import randint |
42 | 42 | ||
43 | +from invesalius import inv_paths | ||
44 | + | ||
43 | FS_ENCODE = sys.getfilesystemencoding() | 45 | FS_ENCODE = sys.getfilesystemencoding() |
44 | 46 | ||
45 | -if sys.platform == 'win32': | ||
46 | - from invesalius.expanduser import expand_user | ||
47 | - try: | ||
48 | - USER_DIR = expand_user() | ||
49 | - except: | ||
50 | - USER_DIR = decode(os.path.expanduser('~'), FS_ENCODE) | ||
51 | -else: | ||
52 | - USER_DIR = decode(os.path.expanduser('~'), FS_ENCODE) | ||
53 | - | ||
54 | -USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius') | ||
55 | -USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets') | ||
56 | -USER_LOG_DIR = os.path.join(USER_INV_DIR, u'logs') | ||
57 | -USER_INV_CFG_PATH = os.path.join(USER_INV_DIR, 'config.json') | ||
58 | -OLD_USER_INV_CFG_PATH = os.path.join(USER_INV_DIR, 'config.cfg') | 47 | +USER_INV_CFG_PATH = os.path.join(inv_paths.USER_INV_DIR, 'config.json') |
48 | +OLD_USER_INV_CFG_PATH = os.path.join(inv_paths.USER_INV_DIR, 'config.cfg') | ||
59 | 49 | ||
60 | SESSION_ENCODING = 'utf8' | 50 | SESSION_ENCODING = 'utf8' |
61 | 51 | ||
@@ -98,8 +88,8 @@ class Session(with_metaclass(Singleton, object)): | @@ -98,8 +88,8 @@ class Session(with_metaclass(Singleton, object)): | ||
98 | 88 | ||
99 | def CreateItens(self): | 89 | def CreateItens(self): |
100 | import invesalius.constants as const | 90 | import invesalius.constants as const |
101 | - homedir = USER_DIR | ||
102 | - tempdir = os.path.join(USER_DIR, u".invesalius", u"temp") | 91 | + homedir = inv_paths.USER_DIR |
92 | + tempdir = os.path.join(inv_paths.USER_DIR, u".invesalius", u"temp") | ||
103 | if not os.path.isdir(tempdir): | 93 | if not os.path.isdir(tempdir): |
104 | os.makedirs(tempdir) | 94 | os.makedirs(tempdir) |
105 | 95 | ||
@@ -116,11 +106,11 @@ class Session(with_metaclass(Singleton, object)): | @@ -116,11 +106,11 @@ class Session(with_metaclass(Singleton, object)): | ||
116 | }, | 106 | }, |
117 | 107 | ||
118 | 'project': { | 108 | 'project': { |
119 | - 'recent_projects': [(const.SAMPLE_DIR, u"Cranium.inv3"), ], | 109 | + 'recent_projects': [(inv_paths.SAMPLE_DIR, u"Cranium.inv3"), ], |
120 | }, | 110 | }, |
121 | 111 | ||
122 | 'paths': { | 112 | 'paths': { |
123 | - 'homedir': USER_DIR, | 113 | + 'homedir': inv_paths.USER_DIR, |
124 | 'tempdir': os.path.join(homedir, u".invesalius", u"temp"), | 114 | 'tempdir': os.path.join(homedir, u".invesalius", u"temp"), |
125 | 'last_dicom_folder': '', | 115 | 'last_dicom_folder': '', |
126 | }, | 116 | }, |