diff --git a/invesalius/constants.py b/invesalius/constants.py index 46ff2a8..b666e72 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -504,3 +504,7 @@ STYLE_LEVEL = {SLICE_STATE_EDITOR: 1, STATE_ZOOM_SL: 2, STATE_PAN:2, VOLUME_STATE_SEED:1} + +#------------ Prefereces options key ------------ +RENDERING = 0 +SURFACE_INTERPOLATION = 1 diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index 521a7bd..1ff51f1 100755 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -74,6 +74,7 @@ class Frame(wx.Frame): # Create aui manager and insert content in it self.__init_aui() + self.preferences = preferences.Preferences(self) # Initialize bind to pubsub events self.__bind_events() self.__bind_events_wx() @@ -324,9 +325,9 @@ class Frame(wx.Frame): evt.Skip() def ShowPreferences(self): - prf = preferences.Preferences(self) - prf.ShowModal() - #print "Show Preferences" + if self.preferences.ShowModal(): + self.preferences.GetPreferences() + self.preferences.Close() def ShowAbout(self): """ diff --git a/invesalius/gui/preferences.py b/invesalius/gui/preferences.py index e25d848..4dc7ac8 100644 --- a/invesalius/gui/preferences.py +++ b/invesalius/gui/preferences.py @@ -1,4 +1,5 @@ import wx +import constants as const ID = wx.NewId() @@ -10,7 +11,7 @@ except ImportError: # if it's not there locally, try the wxPython lib. class Preferences(wx.Dialog): - def __init__( self, parent, id = ID, title = "Preferences", size=wx.DefaultSize,\ + def __init__( self, parent, id = ID, title = _("Preferences"), size=wx.DefaultSize,\ pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE): pre = wx.PreDialog() @@ -25,21 +26,21 @@ class Preferences(wx.Dialog): self.book = fnb.FlatNotebook(self, wx.ID_ANY, agwStyle=bookStyle) sizer.Add(self.book, 80, wx.EXPAND|wx.ALL) - self.pnl_volume_rendering = Viewer3D(self) + self.pnl_viewer3d = Viewer3D(self) self.pnl_language = Language(self) - self.book.AddPage(self.pnl_volume_rendering, "Visualization") - self.book.AddPage(self.pnl_language, "Language") + self.book.AddPage(self.pnl_viewer3d, _("Visualization")) + self.book.AddPage(self.pnl_language, _("Language")) line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() - btn = wx.Button(self, wx.ID_OK, "Apply") + btn = wx.Button(self, wx.ID_OK) btnsizer.AddButton(btn) - btn = wx.Button(self, wx.ID_CANCEL, "Cancel") + btn = wx.Button(self, wx.ID_CANCEL) btnsizer.AddButton(btn) btnsizer.Realize() @@ -48,6 +49,10 @@ class Preferences(wx.Dialog): self.SetSizer(sizer) sizer.Fit(self) + + def GetPreferences(self): + + print ">>>>>>>>>", self.pnl_viewer3d.GetSelection() @@ -58,28 +63,27 @@ class Viewer3D(wx.Panel): wx.Panel.__init__(self, parent, size = wx.Size(800,600)) - box_visualization = wx.StaticBox(self, -1, "Surface") + box_visualization = wx.StaticBox(self, -1, _("Surface")) bsizer = wx.StaticBoxSizer(box_visualization, wx.VERTICAL) - lbl_inter = wx.StaticText(self, -1, "Interpolation ") + lbl_inter = wx.StaticText(self, -1, _("Interpolation ")) bsizer.Add(lbl_inter, 0, wx.TOP|wx.LEFT, 10) - rb_inter = wx.RadioBox(self, -1, "", wx.DefaultPosition, wx.DefaultSize, + rb_inter = self.rb_inter = wx.RadioBox(self, -1, "", wx.DefaultPosition, wx.DefaultSize, ['Flat','Gouraud','Phong'], 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER) bsizer.Add(rb_inter, 0, wx.TOP|wx.LEFT, 0) - box_rendering = wx.StaticBox(self, -1, "Volume Rendering") + box_rendering = wx.StaticBox(self, -1, _("Volume Rendering")) bsizer_ren = wx.StaticBoxSizer(box_rendering, wx.VERTICAL) - lbl_rendering = wx.StaticText(self, -1, "Rendering") + lbl_rendering = wx.StaticText(self, -1, _("Rendering")) bsizer_ren.Add(lbl_rendering, 0, wx.TOP | wx.LEFT, 10) - rb_rendering = wx.RadioBox(self, -1, "", wx.DefaultPosition, wx.DefaultSize, + rb_rendering = self.rb_rendering = wx.RadioBox(self, -1, "", wx.DefaultPosition, wx.DefaultSize, ['CPU', 'GPU (Only NVidia video card)'], 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER) bsizer_ren.Add(rb_rendering, 0, wx.TOP | wx.LEFT, 0) - border = wx.BoxSizer(wx.VERTICAL) border.Add(bsizer, 50, wx.EXPAND|wx.ALL, 10) border.Add(bsizer_ren, 50, wx.EXPAND|wx.ALL, 10) @@ -87,6 +91,14 @@ class Viewer3D(wx.Panel): border.Fit(self) + + def GetSelection(self): + + options = {const.RENDERING:self.rb_rendering.GetSelection(), + const.SURFACE_INTERPOLATION:self.rb_inter.GetSelection()} + + return options + class Language(wx.Panel): def __init__(self, parent): diff --git a/invesalius/session.py b/invesalius/session.py index 062d703..3a4fb27 100644 --- a/invesalius/session.py +++ b/invesalius/session.py @@ -25,7 +25,6 @@ class Session(object): import constants as const self.project_path = () self.debug = False - self.project_status = const.PROJ_CLOSE # const.PROJ_NEW*, const.PROJ_OPEN, const.PROJ_CHANGE*, # const.PROJ_CLOSE @@ -47,7 +46,8 @@ class Session(object): # Recent projects list self.recent_projects = [(const.SAMPLE_DIR, "Cranium.inv3")] self.last_dicom_folder = '' - + self.surface_interpolation = 0 + self.rendering = 0 self.CreateSessionFile() def StopRecording(self, pubsub_evt): @@ -64,13 +64,13 @@ class Session(object): homedir = self.homedir = os.path.expanduser('~') try: path = os.path.join(self.homedir , - '.invesalius', 'config.backup') + '.invesalius', 'config.backup') path_dst = os.path.join(self.homedir , - '.invesalius', 'config.cfg') + '.invesalius', 'config.cfg') shutil.copy(path, path_dst) return True except(IOError): - return False + return False def CloseProject(self): @@ -132,6 +132,8 @@ class Session(object): config.set('session', 'status', self.project_status) config.set('session','debug', self.debug) config.set('session', 'language', self.language) + config.set('session', 'surface_interpolation', self.surface_interpolation) + config.set('session', 'rendering', self.rendering) config.add_section('project') config.set('project', 'recent_projects', self.recent_projects) @@ -204,15 +206,19 @@ class Session(object): self.project_status = config.get('session', 'status') self.debug = config.get('session','debug') self.language = config.get('session','language') + self.recent_projects = eval(config.get('project','recent_projects')) self.homedir = config.get('paths','homedir') self.tempdir = config.get('paths','tempdir') self.last_dicom_folder = config.get('paths','last_dicom_folder') self.last_dicom_folder = self.last_dicom_folder.decode('utf-8') - return True - except(ConfigParser.NoSectionError, ConfigParser.NoOptionError, - ConfigParser.MissingSectionHeaderError, ConfigParser.ParsingError): + self.surface_interpolation = config.get('session', 'surface_interpolation') + self.rendering = config.get('session', 'rendering') + #return True + + except(ConfigParser.NoSectionError, ConfigParser.MissingSectionHeaderError, + ConfigParser.ParsingError): if (self.RecoveryConfigFile()): self.ReadSession() @@ -220,6 +226,14 @@ class Session(object): else: return False + except(ConfigParser.NoOptionError): + #Added to fix new version compatibility + self.surface_interpolation = 0 + self.rendering = 0 + + self.CreateSessionFile() + return True + class WriteSession(Thread): @@ -249,6 +263,8 @@ class WriteSession(Thread): config.set('session', 'status', self.session.project_status) config.set('session','debug', self.session.debug) config.set('session', 'language', self.session.language) + config.set('session', 'surface_interpolation', self.session.surface_interpolation) + config.set('session', 'rendering', self.session.rendering) config.add_section('project') config.set('project', 'recent_projects', self.session.recent_projects) -- libgit2 0.21.2