Commit d1fe1aa719d6cf5afe6616f0f4d9b3e1754b64a0
1 parent
1a0428b5
Exists in
master
and in
68 other branches
FIX: Saving and opening the edited points
Showing
1 changed file
with
14 additions
and
0 deletions
Show diff stats
invesalius/data/mask.py
| ... | ... | @@ -49,6 +49,11 @@ class Mask(): |
| 49 | 49 | img_name = '%s_%s.vti' % (filename, key) |
| 50 | 50 | iu.Export(d[key], img_name, bin=True) |
| 51 | 51 | mask[key] = {'$vti': img_name} |
| 52 | + elif key == 'edited_points': | |
| 53 | + edited_points = {} | |
| 54 | + for p in self.edited_points: | |
| 55 | + edited_points[str(p)] = self.edited_points[p] | |
| 56 | + mask[key] = edited_points | |
| 52 | 57 | else: |
| 53 | 58 | mask[key] = d[key] |
| 54 | 59 | plistlib.writePlist(mask, filename + '.plist') |
| ... | ... | @@ -58,11 +63,20 @@ class Mask(): |
| 58 | 63 | mask = plistlib.readPlist(filename) |
| 59 | 64 | dirpath = os.path.split(filename)[0] |
| 60 | 65 | for key in mask: |
| 66 | + print "Key", key | |
| 61 | 67 | if key == 'imagedata': |
| 62 | 68 | filepath = os.path.split(mask[key]["$vti"])[-1] |
| 63 | 69 | path = os.path.join(dirpath, filepath) |
| 64 | 70 | self.imagedata = iu.Import(path) |
| 71 | + elif key == 'edited_points': | |
| 72 | + edited_points = {} | |
| 73 | + for p in mask[key]: | |
| 74 | + k = [float(i) for i in p.replace('(', '').replace(')', '').split(',')] | |
| 75 | + print k | |
| 76 | + edited_points[tuple(k)] = mask[key][p] | |
| 77 | + setattr(self, key, edited_points) | |
| 65 | 78 | else: |
| 66 | 79 | setattr(self, key, mask[key]) |
| 80 | + print "edited points", self.edited_points | |
| 67 | 81 | |
| 68 | 82 | ... | ... |