Commit 55e04e1f4066d2a4629f682a52cc9cbb151a958a
1 parent
1db06cb6
Exists in
master
and in
68 other branches
FIX: 196, error on config parser (all characters messed up)
Showing
3 changed files
with
20 additions
and
15 deletions
Show diff stats
invesalius/data/slice_.py
| @@ -88,15 +88,22 @@ class Slice(object): | @@ -88,15 +88,22 @@ class Slice(object): | ||
| 88 | ps.Publisher().subscribe(self.OnDuplicateMasks, 'Duplicate masks') | 88 | ps.Publisher().subscribe(self.OnDuplicateMasks, 'Duplicate masks') |
| 89 | 89 | ||
| 90 | def OnRemoveMasks(self, pubsub_evt): | 90 | def OnRemoveMasks(self, pubsub_evt): |
| 91 | + print "slice_: OnRemoveMasks" | ||
| 91 | selected_items = pubsub_evt.data | 92 | selected_items = pubsub_evt.data |
| 93 | + print "selected_items:", selected_items | ||
| 92 | proj = Project() | 94 | proj = Project() |
| 95 | + print "1", proj.mask_dict | ||
| 93 | for item in selected_items: | 96 | for item in selected_items: |
| 94 | proj.RemoveMask(item) | 97 | proj.RemoveMask(item) |
| 98 | + print "2", proj.mask_dict | ||
| 95 | #index = self.current_mask.index | 99 | #index = self.current_mask.index |
| 100 | + print "current_mask", self.current_mask.index | ||
| 96 | if (proj.mask_dict) and (self.current_mask.index in selected_items): | 101 | if (proj.mask_dict) and (self.current_mask.index in selected_items): |
| 102 | + print "first mask exist" | ||
| 97 | self.current_mask = proj.mask_dict[0] | 103 | self.current_mask = proj.mask_dict[0] |
| 98 | self.SelectCurrentMask(0) | 104 | self.SelectCurrentMask(0) |
| 99 | elif not proj.mask_dict: | 105 | elif not proj.mask_dict: |
| 106 | + print "no mask" | ||
| 100 | self.blend_filter.SetOpacity(1, 0) | 107 | self.blend_filter.SetOpacity(1, 0) |
| 101 | self.blend_filter.Update() | 108 | self.blend_filter.Update() |
| 102 | ps.Publisher().sendMessage('Update slice viewer') | 109 | ps.Publisher().sendMessage('Update slice viewer') |
| @@ -208,6 +215,8 @@ class Slice(object): | @@ -208,6 +215,8 @@ class Slice(object): | ||
| 208 | def __show_mask(self, pubsub_evt): | 215 | def __show_mask(self, pubsub_evt): |
| 209 | # "if" is necessary because wx events are calling this before any mask | 216 | # "if" is necessary because wx events are calling this before any mask |
| 210 | # has been created | 217 | # has been created |
| 218 | + print "__show_mask" | ||
| 219 | + print "self.current_mask", self.current_mask | ||
| 211 | if self.current_mask: | 220 | if self.current_mask: |
| 212 | index, value = pubsub_evt.data | 221 | index, value = pubsub_evt.data |
| 213 | self.ShowMask(index, value) | 222 | self.ShowMask(index, value) |
| @@ -359,6 +368,8 @@ class Slice(object): | @@ -359,6 +368,8 @@ class Slice(object): | ||
| 359 | # This condition is not necessary in Linux, only under mac and windows | 368 | # This condition is not necessary in Linux, only under mac and windows |
| 360 | # because combobox event is binded when the same item is selected again. | 369 | # because combobox event is binded when the same item is selected again. |
| 361 | #if index != self.current_mask.index: | 370 | #if index != self.current_mask.index: |
| 371 | + print "SelectCurrentMask" | ||
| 372 | + print "index:", index | ||
| 362 | if self.current_mask and self.blend_filter and index > -1: | 373 | if self.current_mask and self.blend_filter and index > -1: |
| 363 | proj = Project() | 374 | proj = Project() |
| 364 | future_mask = proj.GetMask(index) | 375 | future_mask = proj.GetMask(index) |
| @@ -367,6 +378,7 @@ class Slice(object): | @@ -367,6 +378,7 @@ class Slice(object): | ||
| 367 | 378 | ||
| 368 | colour = future_mask.colour | 379 | colour = future_mask.colour |
| 369 | #index = future_mask.index | 380 | #index = future_mask.index |
| 381 | + print index | ||
| 370 | self.SetMaskColour(index, colour, update=False) | 382 | self.SetMaskColour(index, colour, update=False) |
| 371 | 383 | ||
| 372 | imagedata = future_mask.imagedata | 384 | imagedata = future_mask.imagedata |
invesalius/gui/data_notebook.py
| @@ -324,9 +324,11 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -324,9 +324,11 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
| 324 | self.ToggleItem(evt.m_itemIndex) | 324 | self.ToggleItem(evt.m_itemIndex) |
| 325 | 325 | ||
| 326 | def OnCheckItem(self, index, flag): | 326 | def OnCheckItem(self, index, flag): |
| 327 | + print "OnCheckItem", index, flag | ||
| 327 | if flag: | 328 | if flag: |
| 328 | for key in self.mask_list_index.keys(): | 329 | for key in self.mask_list_index.keys(): |
| 329 | if key != index: | 330 | if key != index: |
| 331 | + print "x" | ||
| 330 | self.SetItemImage(key, 0) | 332 | self.SetItemImage(key, 0) |
| 331 | ps.Publisher().sendMessage('Change mask selected',index) | 333 | ps.Publisher().sendMessage('Change mask selected',index) |
| 332 | self.current_index = index | 334 | self.current_index = index |
invesalius/session.py
| @@ -144,19 +144,6 @@ class Session(object): | @@ -144,19 +144,6 @@ class Session(object): | ||
| 144 | for i in xrange(len(l)-const.PROJ_MAX): | 144 | for i in xrange(len(l)-const.PROJ_MAX): |
| 145 | l.pop() | 145 | l.pop() |
| 146 | 146 | ||
| 147 | - def SavePlist(self): | ||
| 148 | - filename = 'session.conf' | ||
| 149 | - filepath = os.join(self.tempdir, filename) | ||
| 150 | - plistlib.writePlist(self.__dict__, filepath) | ||
| 151 | - | ||
| 152 | - def OpenPlist(self): | ||
| 153 | - filename = 'session.conf' | ||
| 154 | - filepath = os.join(self.tempdir, filename) | ||
| 155 | - # TODO: try/except | ||
| 156 | - dict = plistlib.readPlist(main_plist) | ||
| 157 | - for key in dict: | ||
| 158 | - setattr(self, key, dict[key]) | ||
| 159 | - | ||
| 160 | def GetLanguage(self): | 147 | def GetLanguage(self): |
| 161 | return self.language | 148 | return self.language |
| 162 | 149 | ||
| @@ -178,7 +165,9 @@ class Session(object): | @@ -178,7 +165,9 @@ class Session(object): | ||
| 178 | config.read(path) | 165 | config.read(path) |
| 179 | self.language = config.get('session','language') | 166 | self.language = config.get('session','language') |
| 180 | return self.language | 167 | return self.language |
| 181 | - except(ConfigParser.NoSectionError, ConfigParser.NoOptionError): | 168 | + except (ConfigParser.NoSectionError, |
| 169 | + ConfigParser.NoOptionError, | ||
| 170 | + ConfigParser.MissingSectionHeaderError): | ||
| 182 | return False | 171 | return False |
| 183 | 172 | ||
| 184 | def ReadSession(self): | 173 | def ReadSession(self): |
| @@ -197,7 +186,9 @@ class Session(object): | @@ -197,7 +186,9 @@ class Session(object): | ||
| 197 | self.tempdir = config.get('paths','tempdir') | 186 | self.tempdir = config.get('paths','tempdir') |
| 198 | self.last_dicom_folder = config.get('paths','last_dicom_folder') | 187 | self.last_dicom_folder = config.get('paths','last_dicom_folder') |
| 199 | return True | 188 | return True |
| 200 | - except(ConfigParser.NoSectionError, ConfigParser.NoOptionError): | 189 | + except(ConfigParser.NoSectionError, |
| 190 | + ConfigParser.NoOptionError, | ||
| 191 | + ConfigParser.MissingSectionHeaderError): | ||
| 201 | return False | 192 | return False |
| 202 | 193 | ||
| 203 | 194 |