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 | 54 | session = ses.Session() |
55 | 55 | self.measure_manager = data.measures.MeasurementManager() |
56 | 56 | |
57 | + ps.Publisher().sendMessage('Load Preferences') | |
58 | + | |
57 | 59 | |
58 | 60 | def __bind_events(self): |
59 | 61 | ps.Publisher().subscribe(self.OnImportMedicalImages, 'Import directory') |
... | ... | @@ -343,7 +345,7 @@ class Controller(): |
343 | 345 | |
344 | 346 | def LoadProject(self): |
345 | 347 | proj = prj.Project() |
346 | - | |
348 | + | |
347 | 349 | const.THRESHOLD_OUTVALUE = proj.threshold_range[0] |
348 | 350 | const.THRESHOLD_INVALUE = proj.threshold_range[1] |
349 | 351 | |
... | ... | @@ -353,7 +355,8 @@ class Controller(): |
353 | 355 | ps.Publisher().sendMessage('Load slice to viewer', |
354 | 356 | (proj.imagedata, |
355 | 357 | proj.mask_dict)) |
356 | - ps.Publisher().sendMessage('Load slice plane') | |
358 | + | |
359 | + | |
357 | 360 | ps.Publisher().sendMessage('Bright and contrast adjustment image',\ |
358 | 361 | (proj.window, proj.level)) |
359 | 362 | ps.Publisher().sendMessage('Update window level value',\ |
... | ... | @@ -365,6 +368,7 @@ class Controller(): |
365 | 368 | ps.Publisher().sendMessage('Hide surface items', |
366 | 369 | proj.surface_dict) |
367 | 370 | self.LoadImagedataInfo() # TODO: where do we insert this <<<? |
371 | + | |
368 | 372 | ps.Publisher().sendMessage('Show content panel') |
369 | 373 | ps.Publisher().sendMessage('Update AUI') |
370 | 374 | |
... | ... | @@ -376,6 +380,7 @@ class Controller(): |
376 | 380 | proj.measurement_dict) |
377 | 381 | |
378 | 382 | proj.presets.thresh_ct[_('Custom')] = proj.threshold_range |
383 | + | |
379 | 384 | ps.Publisher().sendMessage('End busy cursor') |
380 | 385 | |
381 | 386 | def CreateAnalyzeProject(self, imagedata): | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -326,8 +326,11 @@ class Frame(wx.Frame): |
326 | 326 | |
327 | 327 | def ShowPreferences(self): |
328 | 328 | if self.preferences.ShowModal(): |
329 | - self.preferences.GetPreferences() | |
329 | + values = self.preferences.GetPreferences() | |
330 | 330 | self.preferences.Close() |
331 | + | |
332 | + ses.Session().rendering = values[const.RENDERING] | |
333 | + ses.Session().surface_interpolation = values[const.SURFACE_INTERPOLATION] | |
331 | 334 | |
332 | 335 | def ShowAbout(self): |
333 | 336 | """ | ... | ... |
invesalius/gui/preferences.py
1 | 1 | import wx |
2 | 2 | import constants as const |
3 | +import wx.lib.pubsub as ps | |
4 | +import session as ses | |
3 | 5 | |
4 | 6 | ID = wx.NewId() |
5 | 7 | |
... | ... | @@ -50,9 +52,22 @@ class Preferences(wx.Dialog): |
50 | 52 | self.SetSizer(sizer) |
51 | 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 | 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 | 114 | |
100 | 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 | 124 | class Language(wx.Panel): |
103 | 125 | |
104 | 126 | def __init__(self, parent): | ... | ... |