Commit 96ff1ceace5facefe3d4452ee9c5cddf2a059c5f
1 parent
4f41c5b0
Exists in
master
and in
5 other branches
ENH: Load preferences init InVesalius
Showing
3 changed files
with
34 additions
and
4 deletions
Show diff stats
invesalius/control.py
@@ -54,6 +54,8 @@ class Controller(): | @@ -54,6 +54,8 @@ class Controller(): | ||
54 | session = ses.Session() | 54 | session = ses.Session() |
55 | self.measure_manager = data.measures.MeasurementManager() | 55 | self.measure_manager = data.measures.MeasurementManager() |
56 | 56 | ||
57 | + ps.Publisher().sendMessage('Load Preferences') | ||
58 | + | ||
57 | 59 | ||
58 | def __bind_events(self): | 60 | def __bind_events(self): |
59 | ps.Publisher().subscribe(self.OnImportMedicalImages, 'Import directory') | 61 | ps.Publisher().subscribe(self.OnImportMedicalImages, 'Import directory') |
@@ -343,7 +345,7 @@ class Controller(): | @@ -343,7 +345,7 @@ class Controller(): | ||
343 | 345 | ||
344 | def LoadProject(self): | 346 | def LoadProject(self): |
345 | proj = prj.Project() | 347 | proj = prj.Project() |
346 | - | 348 | + |
347 | const.THRESHOLD_OUTVALUE = proj.threshold_range[0] | 349 | const.THRESHOLD_OUTVALUE = proj.threshold_range[0] |
348 | const.THRESHOLD_INVALUE = proj.threshold_range[1] | 350 | const.THRESHOLD_INVALUE = proj.threshold_range[1] |
349 | 351 | ||
@@ -353,7 +355,8 @@ class Controller(): | @@ -353,7 +355,8 @@ class Controller(): | ||
353 | ps.Publisher().sendMessage('Load slice to viewer', | 355 | ps.Publisher().sendMessage('Load slice to viewer', |
354 | (proj.imagedata, | 356 | (proj.imagedata, |
355 | proj.mask_dict)) | 357 | proj.mask_dict)) |
356 | - ps.Publisher().sendMessage('Load slice plane') | 358 | + |
359 | + | ||
357 | ps.Publisher().sendMessage('Bright and contrast adjustment image',\ | 360 | ps.Publisher().sendMessage('Bright and contrast adjustment image',\ |
358 | (proj.window, proj.level)) | 361 | (proj.window, proj.level)) |
359 | ps.Publisher().sendMessage('Update window level value',\ | 362 | ps.Publisher().sendMessage('Update window level value',\ |
@@ -365,6 +368,7 @@ class Controller(): | @@ -365,6 +368,7 @@ class Controller(): | ||
365 | ps.Publisher().sendMessage('Hide surface items', | 368 | ps.Publisher().sendMessage('Hide surface items', |
366 | proj.surface_dict) | 369 | proj.surface_dict) |
367 | self.LoadImagedataInfo() # TODO: where do we insert this <<<? | 370 | self.LoadImagedataInfo() # TODO: where do we insert this <<<? |
371 | + | ||
368 | ps.Publisher().sendMessage('Show content panel') | 372 | ps.Publisher().sendMessage('Show content panel') |
369 | ps.Publisher().sendMessage('Update AUI') | 373 | ps.Publisher().sendMessage('Update AUI') |
370 | 374 | ||
@@ -376,6 +380,7 @@ class Controller(): | @@ -376,6 +380,7 @@ class Controller(): | ||
376 | proj.measurement_dict) | 380 | proj.measurement_dict) |
377 | 381 | ||
378 | proj.presets.thresh_ct[_('Custom')] = proj.threshold_range | 382 | proj.presets.thresh_ct[_('Custom')] = proj.threshold_range |
383 | + | ||
379 | ps.Publisher().sendMessage('End busy cursor') | 384 | ps.Publisher().sendMessage('End busy cursor') |
380 | 385 | ||
381 | def CreateAnalyzeProject(self, imagedata): | 386 | def CreateAnalyzeProject(self, imagedata): |
invesalius/gui/frame.py
@@ -326,8 +326,11 @@ class Frame(wx.Frame): | @@ -326,8 +326,11 @@ class Frame(wx.Frame): | ||
326 | 326 | ||
327 | def ShowPreferences(self): | 327 | def ShowPreferences(self): |
328 | if self.preferences.ShowModal(): | 328 | if self.preferences.ShowModal(): |
329 | - self.preferences.GetPreferences() | 329 | + values = self.preferences.GetPreferences() |
330 | self.preferences.Close() | 330 | self.preferences.Close() |
331 | + | ||
332 | + ses.Session().rendering = values[const.RENDERING] | ||
333 | + ses.Session().surface_interpolation = values[const.SURFACE_INTERPOLATION] | ||
331 | 334 | ||
332 | def ShowAbout(self): | 335 | def ShowAbout(self): |
333 | """ | 336 | """ |
invesalius/gui/preferences.py
1 | import wx | 1 | import wx |
2 | import constants as const | 2 | import constants as const |
3 | +import wx.lib.pubsub as ps | ||
4 | +import session as ses | ||
3 | 5 | ||
4 | ID = wx.NewId() | 6 | ID = wx.NewId() |
5 | 7 | ||
@@ -50,9 +52,22 @@ class Preferences(wx.Dialog): | @@ -50,9 +52,22 @@ class Preferences(wx.Dialog): | ||
50 | self.SetSizer(sizer) | 52 | self.SetSizer(sizer) |
51 | sizer.Fit(self) | 53 | sizer.Fit(self) |
52 | 54 | ||
55 | + self.__bind_events() | ||
56 | + | ||
57 | + def __bind_events(self): | ||
58 | + ps.Publisher().subscribe(self.LoadPreferences, 'Load Preferences') | ||
59 | + | ||
60 | + | ||
53 | def GetPreferences(self): | 61 | def GetPreferences(self): |
54 | 62 | ||
55 | - print ">>>>>>>>>", self.pnl_viewer3d.GetSelection() | 63 | + return self.pnl_viewer3d.GetSelection() |
64 | + | ||
65 | + def LoadPreferences(self, pub_evt): | ||
66 | + | ||
67 | + values = {const.RENDERING:ses.Session().rendering, | ||
68 | + const.SURFACE_INTERPOLATION:ses.Session().surface_interpolation} | ||
69 | + | ||
70 | + self.pnl_viewer3d.LoadSelection(values) | ||
56 | 71 | ||
57 | 72 | ||
58 | 73 | ||
@@ -99,6 +114,13 @@ class Viewer3D(wx.Panel): | @@ -99,6 +114,13 @@ class Viewer3D(wx.Panel): | ||
99 | 114 | ||
100 | return options | 115 | return options |
101 | 116 | ||
117 | + def LoadSelection(self, values): | ||
118 | + rendering = values[const.RENDERING] | ||
119 | + surface_interpolation = values[const.SURFACE_INTERPOLATION] | ||
120 | + | ||
121 | + self.rb_rendering.SetSelection(int(rendering)) | ||
122 | + self.rb_inter.SetSelection(int(surface_interpolation)) | ||
123 | + | ||
102 | class Language(wx.Panel): | 124 | class Language(wx.Panel): |
103 | 125 | ||
104 | def __init__(self, parent): | 126 | def __init__(self, parent): |