Commit f37e46c7 authored by Thiago Franco de Moraes's avatar Thiago Franco de Moraes
Browse files

New upstream version 3.1.99993

parent f6db4e7b
Loading
Loading
Loading
Loading
+42 −36
Original line number Diff line number Diff line
#!/usr/bin/python
#!/usr/bin/env python3
#--------------------------------------------------------------------------
# Software:     InVesalius - Software de Reconstrucao 3D de Imagens Medicas
# Copyright:    (C) 2001  Centro de Pesquisas Renato Archer
@@ -65,21 +65,9 @@ import invesalius.i18n as i18n
import invesalius.session as ses
import invesalius.utils as utils

FS_ENCODE = sys.getfilesystemencoding()

if sys.platform == 'win32':
    from invesalius.expanduser import expand_user
    try:
        USER_DIR = expand_user()
    except:
        USER_DIR = utils.decode(os.path.expanduser('~'), FS_ENCODE)
else:
    USER_DIR = utils.decode(os.path.expanduser('~'),FS_ENCODE)
from invesalius import inv_paths

USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius')
USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets')
USER_RAYCASTING_PRESETS_DIRECTORY = os.path.join(USER_PRESET_DIR, u'raycasting')
USER_LOG_DIR = os.path.join(USER_INV_DIR, u'logs')
FS_ENCODE = sys.getfilesystemencoding()

# ------------------------------------------------------------------

@@ -147,9 +135,8 @@ class Inv3SplashScreen(SplashScreen):
            create_session = True

        install_lang = 0
        # Check if there is a language set (if session file exists
        if session.ReadLanguage():
        lang = session.GetLanguage()
        if lang:
            if (lang != "False"):
                _ = i18n.InstallLanguage(lang)
                install_lang = 1
@@ -180,6 +167,8 @@ class Inv3SplashScreen(SplashScreen):
                    shutil.rmtree(invdir)
                    sys.exit()

            dialog.Destroy()

        # Session file should be created... So we set the recent
        # choosen language
        if (create_session):
@@ -187,18 +176,20 @@ class Inv3SplashScreen(SplashScreen):
            session.SetLanguage(lang)
            session.WriteSessionFile()

        session.SaveConfigFileBackup()
        #  session.SaveConfigFileBackup()

           
        # Only after language was defined, splash screen will be
        # shown
        if lang:
            #  print "LANG", lang, _, wx.Locale(), wx.GetLocale()
            import locale
            try:
                locale.setlocale(locale.LC_ALL, '')
            except locale.Error:
                pass
            
            #import locale
            #try:
            #    locale.setlocale(locale.LC_ALL, '')
            #except locale.Error:
            #    pass
            
            
            # For pt_BR, splash_pt.png should be used
            if (lang.startswith('pt')):
                icon_file = "splash_pt.png"
@@ -244,9 +235,9 @@ class Inv3SplashScreen(SplashScreen):
        self.main = Frame(None)
        self.control = Controller(self.main)
        
        self.fc = wx.FutureCall(1, self.ShowMain)
        self.fc = wx.CallLater(200, self.ShowMain)
        options, args = parse_comand_line()
        wx.FutureCall(1, use_cmd_optargs, options, args)
        wx.CallLater(1, use_cmd_optargs, options, args)

        # Check for updates
        from threading import Thread
@@ -333,6 +324,13 @@ def parse_comand_line():
    parser.add_option("-a", "--export-to-all",
                      help="Export to STL for all mask presets.")

    parser.add_option("--export-project",
                      help="Export slices and mask to HDF5 or Nifti file.")

    parser.add_option("--no-masks", action="store_false",
                      dest="save_masks", default=True,
                      help="Make InVesalius not export mask when exporting project.")

    options, args = parser.parse_args()
    return options, args

@@ -426,6 +424,17 @@ def check_for_export(options, suffix='', remove_surfaces=False):
        finally:
            exit(0)

    if options.export_project:
        from invesalius.project import Project
        prj = Project()
        export_filename = options.export_project
        if suffix:
            export_filename, ext = os.path.splitext(export_filename)
            export_filename = u'{}-{}{}'.format(export_filename, suffix, ext)

        prj.export_project(export_filename, save_masks=options.save_masks)
        print("Saved {}".format(export_filename))


def export(path_, threshold_range, remove_surface=False):
    import invesalius.constants as const
@@ -489,17 +498,14 @@ if __name__ == '__main__':

        os.chdir(path)

    # Create raycasting presets' folder, if it doens't exist
    if not os.path.isdir(USER_RAYCASTING_PRESETS_DIRECTORY):
        os.makedirs(USER_RAYCASTING_PRESETS_DIRECTORY)

    # Create logs' folder, if it doesn't exist
    if not os.path.isdir(USER_LOG_DIR):
        os.makedirs(USER_LOG_DIR)
    if not inv_paths.USER_INV_DIR.exists():
        inv_paths.create_conf_folders()
        if inv_paths.OLD_USER_INV_DIR.exists():
            inv_paths.copy_old_files()

    if hasattr(sys,"frozen") and sys.frozen == "windows_exe":
        # Set system standard error output to file
        path = os.path.join(USER_LOG_DIR, u"stderr.log")
        path = inv_paths.USER_LOG_DIR.join("stderr.log")
        sys.stderr = open(path, "w")

    # Add current directory to PYTHONPATH, so other classes can

icons/be.bmp

0 → 100644
+1.57 KiB
Loading image diff...
+1.43 KiB
Loading image diff...
+1.45 KiB
Loading image diff...
+1.63 KiB
Loading image diff...
Loading