Commit 6261edc12497004c2a5d9004c1a171e28d2222a6

Authored by Thiago Franco de Moraes
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
app.py
... ... @@ -65,21 +65,9 @@ import invesalius.i18n as i18n
65 65 import invesalius.session as ses
66 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 498  
511 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 506 if hasattr(sys,"frozen") and sys.frozen == "windows_exe":
522 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 509 sys.stderr = open(path, "w")
525 510  
526 511 # Add current directory to PYTHONPATH, so other classes can
... ...
invesalius/constants.py
... ... @@ -24,6 +24,7 @@ import wx
24 24 import itertools
25 25  
26 26 from invesalius import utils
  27 +from invesalius import inv_paths
27 28  
28 29 #from invesalius.project import Project
29 30 INVESALIUS_VERSION = "3.1.1"
... ... @@ -335,59 +336,13 @@ REDUCE_IMAGEDATA_QUALITY = 0
335 336 # PATHS
336 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 348 # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper
... ... @@ -433,10 +388,9 @@ RAYCASTING_FILES = {_("Airways"): "Airways.plist",
433 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 394 RAYCASTING_TYPES += RAYCASTING_FILES.keys()
441 395 RAYCASTING_TYPES.append(_(' Off'))
442 396 RAYCASTING_TYPES.sort()
... ... @@ -446,8 +400,8 @@ RAYCASTING_TOOLS = [_("Cut plane")]
446 400 # If 0 dont't blur, 1 blur
447 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 715 _("Select object center"),
762 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 718 PROBE_NAME = "1Probe"
767 719 REF_NAME = "2Ref"
768 720 OBJ_NAME = "3Coil"
769 721  
770 722 #OBJECT TRACKING
771   -OBJ_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'objects'))
772 723 ARROW_SCALE = 3
773 724 ARROW_UPPER_LIMIT = 30
774 725 #COIL_ANGLES_THRESHOLD = 3 * ARROW_SCALE
... ...
invesalius/control.py
... ... @@ -42,6 +42,8 @@ import invesalius.gui.dialogs as dialogs
42 42 import subprocess
43 43 import sys
44 44  
  45 +from invesalius import inv_paths
  46 +
45 47 DEFAULT_THRESH_MODE = 0
46 48  
47 49 class Controller():
... ... @@ -920,13 +922,13 @@ class Controller():
920 922 def LoadRaycastingPreset(self, preset_name):
921 923 if preset_name != const.RAYCASTING_OFF_LABEL:
922 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 926 const.RAYCASTING_FILES[preset_name])
925 927 else:
926   - path = os.path.join(const.RAYCASTING_PRESETS_DIRECTORY,
  928 + path = os.path.join(inv_paths.RAYCASTING_PRESETS_DIRECTORY,
927 929 preset_name+".plist")
928 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 932 preset_name+".plist")
931 933 preset = plistlib.readPlist(path)
932 934 prj.Project().raycasting_preset = preset
... ... @@ -940,7 +942,7 @@ class Controller():
940 942 def SaveRaycastingPreset(self, preset_name):
941 943 preset = prj.Project().raycasting_preset
942 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 946 preset_name + '.plist')
945 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 37 import invesalius.utils as utils
38 38 import invesalius.data.converters as converters
39 39  
  40 +from invesalius import inv_paths
  41 +
40 42 if sys.platform == 'win32':
41 43 try:
42 44 import win32api
... ... @@ -335,7 +337,7 @@ def CreateImageData(filelist, zspacing, xyspacing,size,
335 337 message = _("Generating multiplanar visualization...")
336 338  
337 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 341 fow = vtk.vtkFileOutputWindow()
340 342 fow.SetFileName(log_path)
341 343 ow = vtk.vtkOutputWindow()
... ... @@ -440,7 +442,7 @@ class ImageCreator:
440 442 message = _("Generating multiplanar visualization...")
441 443  
442 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 446 fow = vtk.vtkFileOutputWindow()
445 447 fow.SetFileName(log_path)
446 448 ow = vtk.vtkOutputWindow()
... ...
invesalius/data/trackers.py
... ... @@ -61,6 +61,7 @@ def DefaultTracker(tracker_id):
61 61  
62 62 def ClaronTracker(tracker_id):
63 63 import invesalius.constants as const
  64 + from invesalius import inv_paths
64 65  
65 66 trck_init = None
66 67 try:
... ... @@ -68,8 +69,8 @@ def ClaronTracker(tracker_id):
68 69  
69 70 lib_mode = 'wrapper'
70 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 74 trck_init.NumberFramesProcessed = 1
74 75 trck_init.FramesExtrapolated = 0
75 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 42 import invesalius.style as st
43 43 import invesalius.utils as utils
44 44  
  45 +from invesalius import inv_paths
  46 +
45 47 if sys.platform == 'win32':
46 48 try:
47 49 import win32api
... ... @@ -873,7 +875,7 @@ class Viewer(wx.Panel):
873 875  
874 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 880 reader = vtk.vtkSTLReader()
879 881 reader.SetFileName(filename)
... ... @@ -898,7 +900,7 @@ class Viewer(wx.Panel):
898 900 self.aim_actor = aim_actor
899 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 905 transform = vtk.vtkTransform()
904 906 transform.RotateZ(90)
... ... @@ -1148,7 +1150,7 @@ class Viewer(wx.Panel):
1148 1150 wx.MessageBox(_("File format not reconized by InVesalius"), _("Import surface error"))
1149 1151 return
1150 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 1154 reader = vtk.vtkSTLReader()
1153 1155  
1154 1156 if _has_win32api:
... ...
invesalius/data/volume.py
... ... @@ -33,6 +33,8 @@ import invesalius.data.vtk_utils as vtk_utils
33 33 from vtk.util import numpy_support
34 34 import invesalius.session as ses
35 35  
  36 +from invesalius import inv_paths
  37 +
36 38  
37 39 Kernels = {
38 40 "Basic Smooth 5x5" : [1.0, 1.0, 1.0, 1.0, 1.0,
... ... @@ -352,7 +354,7 @@ class Volume():
352 354 color_preset = self.config['CLUT']
353 355 if color_preset != "No CLUT":
354 356 p = plistlib.readPlist(
355   - os.path.join(const.RAYCASTING_PRESETS_DIRECTORY,
  357 + os.path.join(inv_paths.RAYCASTING_PRESETS_DIRECTORY,
356 358 'color_list', color_preset + '.plist'))
357 359 r = p['Red']
358 360 g = p['Green']
... ...
invesalius/gui/data_notebook.py
... ... @@ -43,6 +43,8 @@ import invesalius.gui.dialogs as dlg
43 43 import wx.lib.mixins.listctrl as listmix
44 44 import invesalius.utils as ul
45 45  
  46 +from invesalius import inv_paths
  47 +
46 48  
47 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 157 def __init_gui(self):
156 158  
157 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 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 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 165 wx.BITMAP_TYPE_PNG)
164 166  
165 167 # Plate buttons based on previous bitmaps
... ... @@ -273,11 +275,11 @@ class ButtonControlPanel(wx.Panel):
273 275 def __init_gui(self):
274 276  
275 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 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 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 283 wx.BITMAP_TYPE_PNG)
282 284  
283 285 # Plate buttons based on previous bitmaps
... ... @@ -473,13 +475,13 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt
473 475 def __init_image_list(self):
474 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 479 bitmap = wx.Bitmap(image.Scale(16, 16))
478 480 bitmap.SetWidth(16)
479 481 bitmap.SetHeight(16)
480 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 485 bitmap = wx.Bitmap(image.Scale(16, 16))
484 486 bitmap.SetWidth(16)
485 487 bitmap.SetHeight(16)
... ... @@ -487,7 +489,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt
487 489  
488 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 494 def OnBeginLabelEdit(self, evt):
493 495 if evt.GetColumn() == 1:
... ... @@ -616,13 +618,13 @@ class SurfaceButtonControlPanel(wx.Panel):
616 618 def __init_gui(self):
617 619  
618 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 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 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 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 628 wx.BITMAP_TYPE_PNG)
627 629  
628 630 # Plate buttons based on previous bitmaps
... ... @@ -839,13 +841,13 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
839 841 def __init_image_list(self):
840 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 845 bitmap = wx.Bitmap(image.Scale(16, 16))
844 846 bitmap.SetWidth(16)
845 847 bitmap.SetHeight(16)
846 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 851 bitmap = wx.Bitmap(image.Scale(16, 16))
850 852 bitmap.SetWidth(16)
851 853 bitmap.SetHeight(16)
... ... @@ -853,7 +855,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
853 855  
854 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 860 def OnBeginLabelEdit(self, evt):
859 861 if evt.GetColumn() == 1:
... ... @@ -1114,13 +1116,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
1114 1116 def __init_image_list(self):
1115 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 1120 bitmap = wx.Bitmap(image.Scale(16, 16))
1119 1121 bitmap.SetWidth(16)
1120 1122 bitmap.SetHeight(16)
1121 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 1126 bitmap = wx.Bitmap(image.Scale(16, 16))
1125 1127 bitmap.SetWidth(16)
1126 1128 bitmap.SetHeight(16)
... ... @@ -1128,7 +1130,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
1128 1130  
1129 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 1135 def OnBeginLabelEdit(self, evt):
1134 1136 if evt.GetColumn() == 1:
... ... @@ -1309,19 +1311,19 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.Check
1309 1311 def __init_image_list(self):
1310 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 1315 bitmap = wx.Bitmap(image.Scale(16, 16))
1314 1316 bitmap.SetWidth(16)
1315 1317 bitmap.SetHeight(16)
1316 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 1321 bitmap = wx.Bitmap(image.Scale(16, 16))
1320 1322 bitmap.SetWidth(16)
1321 1323 bitmap.SetHeight(16)
1322 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 1327 bitmap = wx.Bitmap(image.Scale(16, 16))
1326 1328 bitmap.SetWidth(16)
1327 1329 bitmap.SetHeight(16)
... ...
invesalius/gui/default_viewers.py
... ... @@ -34,6 +34,7 @@ from invesalius.gui.widgets.clut_raycasting import CLUTRaycastingWidget, \
34 34 EVT_CLUT_CURVE_WL_CHANGE
35 35  
36 36 from invesalius.constants import ID_TO_BMP
  37 +from invesalius import inv_paths
37 38  
38 39 import invesalius.session as ses
39 40 import invesalius.constants as const
... ... @@ -348,17 +349,17 @@ class VolumeToolPanel(wx.Panel):
348 349 wx.Panel.__init__(self, parent)
349 350  
350 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 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 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 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 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 64 from invesalius.gui.widgets.clut_imagedata import CLUTImageDataWidget, EVT_CLUT_NODE_CHANGED
65 65 import numpy as np
66 66  
  67 +from invesalius import inv_paths
  68 +
67 69 try:
68 70 from agw import floatspin as FS
69 71 except ImportError: # if it's not there locally, try the wxPython lib.
... ... @@ -3443,10 +3445,10 @@ class ObjectCalibrationDialog(wx.Dialog):
3443 3445 wx.MessageBox(_("File format not reconized by InVesalius"), _("Import surface error"))
3444 3446 return
3445 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 3449 reader = vtk.vtkSTLReader()
3448 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 3452 reader = vtk.vtkSTLReader()
3451 3453  
3452 3454 if _has_win32api:
... ...
invesalius/gui/frame.py
... ... @@ -23,31 +23,31 @@ import platform
23 23 import sys
24 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 26 import invesalius.constants as const
41 27 import invesalius.gui.default_tasks as tasks
42 28 import invesalius.gui.default_viewers as viewers
43 29 import invesalius.gui.dialogs as dlg
44   -import invesalius.gui.import_panel as imp
45 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 33 # import invesalius.gui.import_network_panel as imp_net
47 34 import invesalius.project as prj
48 35 import invesalius.session as ses
49 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 51 # Layout tools' IDs - this is used only locally, therefore doesn't
52 52 # need to be defined in constants.py
53 53 VIEW_TOOLS = [ID_LAYOUT, ID_TEXT] =\
... ... @@ -94,8 +94,8 @@ class Frame(wx.Frame):
94 94 size=wx.Size(1024, 748), #size = wx.DisplaySize(),
95 95 style=wx.DEFAULT_FRAME_STYLE, title='InVesalius 3')
96 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 100 self.mw = None
101 101 self._last_viewer_orientation_focus = const.AXIAL_STR
... ... @@ -621,7 +621,7 @@ class Frame(wx.Frame):
621 621 else:
622 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 625 user_guide)
626 626 if sys.platform == 'darwin':
627 627 path = r'file://' + path
... ... @@ -846,7 +846,7 @@ class MenuBar(wx.MenuBar):
846 846 app(const.ID_EXIT, _("Exit\tCtrl+Q"))
847 847  
848 848 file_edit = wx.Menu()
849   - d = const.ICON_DIR
  849 + d = inv_paths.ICON_DIR
850 850 if not(sys.platform == 'darwin'):
851 851 # Bitmaps for show/hide task panel item
852 852 p = os.path.join(d, "undo_menu.png")
... ... @@ -1284,43 +1284,43 @@ class ProjectToolBar(AuiToolBar):
1284 1284 Add tools into toolbar.
1285 1285 """
1286 1286 # Load bitmaps
1287   - d = const.ICON_DIR
  1287 + d = inv_paths.ICON_DIR
1288 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 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 1325 # Create tool items based on bitmaps
1326 1326 self.AddTool(const.ID_DICOM_IMPORT,
... ... @@ -1436,65 +1436,65 @@ class ObjectToolBar(AuiToolBar):
1436 1436 """
1437 1437 Add tools into toolbar.
1438 1438 """
1439   - d = const.ICON_DIR
  1439 + d = inv_paths.ICON_DIR
1440 1440 if sys.platform == 'darwin':
1441 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 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 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 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 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 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 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 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 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 1468 #path = os.path.join(d, "tool_annotation_original.png")
1469 1469 #BMP_ANNOTATE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG)
1470 1470  
1471 1471 else:
1472 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 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 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 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 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 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 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 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 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 1499 #path = os.path.join(d, "tool_annotation.png")
1500 1500 #BMP_ANNOTATE = wx.Bitmap(path, wx.BITMAP_TYPE_PNG)
... ... @@ -1686,19 +1686,19 @@ class SliceToolBar(AuiToolBar):
1686 1686 """
1687 1687 Add tools into toolbar.
1688 1688 """
1689   - d = const.ICON_DIR
  1689 + d = inv_paths.ICON_DIR
1690 1690 if sys.platform == 'darwin':
1691 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 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 1696 else:
1697 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 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 1703 self.sst = self.AddToggleTool(const.SLICE_STATE_SCROLL,
1704 1704 BMP_SLICE,#, kind=wx.ITEM_CHECK)
... ... @@ -1853,36 +1853,36 @@ class LayoutToolBar(AuiToolBar):
1853 1853 """
1854 1854 Add tools into toolbar.
1855 1855 """
1856   - d = const.ICON_DIR
  1856 + d = inv_paths.ICON_DIR
1857 1857 if sys.platform == 'darwin':
1858 1858 # Bitmaps for show/hide task panel item
1859 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 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 1865 # Bitmaps for show/hide task item
1866 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 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 1872 else:
1873 1873 # Bitmaps for show/hide task panel item
1874 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 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 1880 # Bitmaps for show/hide task item
1881 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 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 1887 self.AddTool(ID_LAYOUT,
1888 1888 "",
... ... @@ -2035,22 +2035,22 @@ class HistoryToolBar(AuiToolBar):
2035 2035 """
2036 2036 Add tools into toolbar.
2037 2037 """
2038   - d = const.ICON_DIR
  2038 + d = inv_paths.ICON_DIR
2039 2039 if sys.platform == 'darwin':
2040 2040 # Bitmaps for show/hide task panel item
2041 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 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 2047 else:
2048 2048 # Bitmaps for show/hide task panel item
2049 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 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 2055 self.AddTool(wx.ID_UNDO,
2056 2056 "",
... ...
invesalius/gui/task_exporter.py
... ... @@ -35,6 +35,8 @@ import invesalius.gui.dialogs as dlg
35 35 import invesalius.project as proj
36 36 import invesalius.session as ses
37 37  
  38 +from invesalius import inv_paths
  39 +
38 40 BTN_MASK = wx.NewId()
39 41 BTN_PICTURE = wx.NewId()
40 42 BTN_SURFACE = wx.NewId()
... ... @@ -170,22 +172,22 @@ class InnerTaskPanel(wx.Panel):
170 172 # Image(s) for buttons
171 173 if sys.platform == 'darwin':
172 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 176 wx.BITMAP_TYPE_PNG).ConvertToImage()\
175 177 .Rescale(25, 25).ConvertToBitmap()
176 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 180 wx.BITMAP_TYPE_PNG).ConvertToImage()\
179 181 .Rescale(25, 25).ConvertToBitmap()
180 182  
181 183 #BMP_EXPORT_MASK = wx.Bitmap("../icons/mask.png",
182 184 # wx.BITMAP_TYPE_PNG)
183 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 187 wx.BITMAP_TYPE_PNG).ConvertToImage()\
186 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 191 wx.BITMAP_TYPE_PNG).ConvertToImage()\
190 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 31 import invesalius.constants as const
32 32 import invesalius.gui.dialogs as dlg
33 33  
  34 +from invesalius import inv_paths
  35 +
34 36 BTN_IMPORT_LOCAL = wx.NewId()
35 37 BTN_IMPORT_PACS = wx.NewId()
36 38 BTN_OPEN_PROJECT = wx.NewId()
... ... @@ -100,9 +102,9 @@ class InnerTaskPanel(wx.Panel):
100 102 link_open_proj.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkOpenProject)
101 103  
102 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 109 bmp_list = [BMP_IMPORT, BMP_NET, BMP_OPEN_PROJECT]
108 110 #for bmp in bmp_list:
... ...
invesalius/gui/task_slice.py
... ... @@ -40,6 +40,8 @@ import invesalius.gui.dialogs as dlg
40 40 import invesalius.gui.widgets.gradient as grad
41 41 from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl
42 42  
  43 +from invesalius import inv_paths
  44 +
43 45 from invesalius.project import Project
44 46 import invesalius.session as ses
45 47  
... ... @@ -78,7 +80,7 @@ class InnerTaskPanel(wx.Panel):
78 80 self.SetAutoLayout(1)
79 81  
80 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 84 #BMP_ADD.SetWidth(25)
83 85 #BMP_ADD.SetHeight(25)
84 86  
... ... @@ -686,11 +688,11 @@ class EditionTools(wx.Panel):
686 688 ## LINE 2
687 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 692 item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, _("Circle"))
691 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 696 item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square"))
695 697 item2.SetBitmap(SQUARE_BMP)
696 698  
... ... @@ -800,8 +802,8 @@ class EditionTools(wx.Panel):
800 802 threshold_range=(thresh_min, thresh_max))
801 803  
802 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 808 brush = {MENU_BRUSH_CIRCLE: const.BRUSH_CIRCLE,
807 809 MENU_BRUSH_SQUARE: const.BRUSH_SQUARE}
... ... @@ -849,11 +851,11 @@ class WatershedTool(EditionTools):
849 851 ## LINE 2
850 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 855 item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, _("Circle"))
854 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 859 item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square"))
858 860 item2.SetBitmap(SQUARE_BMP)
859 861  
... ... @@ -903,7 +905,7 @@ class WatershedTool(EditionTools):
903 905 self.ww_wl_cbox = ww_wl_cbox
904 906  
905 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 909 self.btn_wconfig = wx.BitmapButton(self, -1, bitmap=bmp,
908 910 size=(bmp.GetWidth()+10, bmp.GetHeight()+10))
909 911 self.btn_exp_watershed = wx.Button(self, -1, _('Expand watershed to 3D'))
... ... @@ -970,8 +972,8 @@ class WatershedTool(EditionTools):
970 972 self.gradient_thresh.SetMaxValue(thresh_max)
971 973  
972 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 978 brush = {MENU_BRUSH_CIRCLE: const.BRUSH_CIRCLE,
977 979 MENU_BRUSH_SQUARE: const.BRUSH_SQUARE}
... ...
invesalius/gui/task_surface.py
... ... @@ -38,6 +38,7 @@ import wx.lib.platebtn as pbtn
38 38 import invesalius.project as prj
39 39 import invesalius.utils as utl
40 40  
  41 +from invesalius import inv_paths
41 42 from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl, InvFloatSpinCtrl
42 43  
43 44 #INTERPOLATION_MODE_LIST = ["Cubic", "Linear", "NearestNeighbor"]
... ... @@ -82,7 +83,7 @@ class InnerTaskPanel(wx.Panel):
82 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 87 #BMP_ADD.SetWidth(25)
87 88 #BMP_ADD.SetHeight(25)
88 89  
... ... @@ -330,17 +331,17 @@ class SurfaceTools(wx.Panel):
330 331 link_seeds.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkSeed)
331 332  
332 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 335 wx.BITMAP_TYPE_PNG)
335 336 img_largest.Rescale(25, 25)
336 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 340 wx.BITMAP_TYPE_PNG)
340 341 img_split_all.Rescale(25, 25)
341 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 345 wx.BITMAP_TYPE_PNG)
345 346 img_seeds.Rescale(25, 25)
346 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 29 import invesalius.gui.dialogs as dialog
30 30 import invesalius.constants as const
31 31  
  32 +from invesalius import inv_paths
  33 +
32 34 FONT_COLOUR = (1, 1, 1)
33 35 LINE_COLOUR = (128, 128, 128)
34 36 LINE_WIDTH = 2
... ... @@ -634,7 +636,7 @@ class CLUTRaycastingWidget(wx.Panel):
634 636 self.Histogram.points.append((x, y))
635 637  
636 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 640 width = img.GetWidth()
639 641 height = img.GetHeight()
640 642 self.save_button = Button()
... ...
invesalius/inv_paths.py 0 → 100644
... ... @@ -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 24  
25 25 from wx.lib.pubsub import pub as Publisher
26 26  
  27 +from invesalius import inv_paths
27 28 from invesalius.utils import TwoWaysDictionary
  29 +
  30 +
28 31 class Presets():
29 32  
30 33 def __init__(self):
... ... @@ -169,7 +172,7 @@ class Presets():
169 172  
170 173  
171 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 176 presets = {}
174 177 for f in files:
175 178 p = os.path.splitext(os.path.basename(f))[0]
... ...
invesalius/project.py
... ... @@ -39,6 +39,8 @@ from invesalius.presets import Presets
39 39 from invesalius.utils import Singleton, debug, touch, decode
40 40 import invesalius.version as version
41 41  
  42 +from invesalius import inv_paths
  43 +
42 44 if sys.platform == 'win32':
43 45 try:
44 46 import win32api
... ... @@ -280,7 +282,7 @@ class Project(with_metaclass(Singleton, object)):
280 282 import invesalius.data.surface as srf
281 283  
282 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 286 fow = vtk.vtkFileOutputWindow()
285 287 fow.SetFileName(log_path.encode(const.FS_ENCODE))
286 288 ow = vtk.vtkOutputWindow()
... ...
invesalius/reader/bitmap_reader.py
... ... @@ -35,6 +35,9 @@ import imghdr
35 35  
36 36 import invesalius.utils as utils
37 37 import invesalius.data.converters as converters
  38 +from invesalius import inv_paths
  39 +
  40 +
38 41 #flag to control vtk error in read files
39 42 no_error = True
40 43 vtk_error = False
... ... @@ -299,7 +302,7 @@ def ScipyRead(filepath):
299 302  
300 303 def VtkRead(filepath, t):
301 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 306 fow = vtk.vtkFileOutputWindow()
304 307 fow.SetFileName(log_path.encode(const.FS_ENCODE))
305 308 ow = vtk.vtkOutputWindow()
... ...
invesalius/reader/dicom_reader.py
... ... @@ -35,6 +35,7 @@ import invesalius.session as session
35 35 import glob
36 36 import invesalius.utils as utils
37 37  
  38 +from invesalius import inv_paths
38 39 from invesalius.data import imagedata_utils
39 40  
40 41 import plistlib
... ... @@ -334,7 +335,7 @@ class ProgressDicomReader:
334 335 def GetDicomGroups(self, path, recursive):
335 336  
336 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 339 fow = vtk.vtkFileOutputWindow()
339 340 fow.SetFileName(log_path)
340 341 ow = vtk.vtkOutputWindow()
... ...
invesalius/reader/others_reader.py
... ... @@ -23,6 +23,7 @@ import vtk
23 23 import nibabel as nib
24 24  
25 25 import invesalius.constants as const
  26 +from invesalius import inv_paths
26 27  
27 28  
28 29 def ReadOthers(dir_):
... ... @@ -38,7 +39,7 @@ def ReadOthers(dir_):
38 39 """
39 40  
40 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 43 fow = vtk.vtkFileOutputWindow()
43 44 fow.SetFileName(log_path.encode(const.FS_ENCODE))
44 45 ow = vtk.vtkOutputWindow()
... ...
invesalius/session.py
... ... @@ -40,22 +40,12 @@ import wx
40 40 from invesalius.utils import Singleton, debug, decode
41 41 from random import randint
42 42  
  43 +from invesalius import inv_paths
  44 +
43 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 50 SESSION_ENCODING = 'utf8'
61 51  
... ... @@ -98,8 +88,8 @@ class Session(with_metaclass(Singleton, object)):
98 88  
99 89 def CreateItens(self):
100 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 93 if not os.path.isdir(tempdir):
104 94 os.makedirs(tempdir)
105 95  
... ... @@ -116,11 +106,11 @@ class Session(with_metaclass(Singleton, object)):
116 106 },
117 107  
118 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 112 'paths': {
123   - 'homedir': USER_DIR,
  113 + 'homedir': inv_paths.USER_DIR,
124 114 'tempdir': os.path.join(homedir, u".invesalius", u"temp"),
125 115 'last_dicom_folder': '',
126 116 },
... ...