Commit ee819756337b4e644b28129f5e50fab7f1e1e35c
1 parent
a9f22507
Exists in
master
and in
68 other branches
ADD: Project status, OPEN_PROJECT, NEW_PROJECT and SAVE_PROJECT
Showing
4 changed files
with
14 additions
and
6 deletions
Show diff stats
invesalius/control.py
| @@ -33,6 +33,7 @@ import reader.dicom_grouper as dg | @@ -33,6 +33,7 @@ import reader.dicom_grouper as dg | ||
| 33 | import gui.dialogs as dialog | 33 | import gui.dialogs as dialog |
| 34 | import reader.dicom_reader as dcm | 34 | import reader.dicom_reader as dcm |
| 35 | import reader.analyze_reader as analyze | 35 | import reader.analyze_reader as analyze |
| 36 | +import session | ||
| 36 | 37 | ||
| 37 | DEFAULT_THRESH_MODE = 0 | 38 | DEFAULT_THRESH_MODE = 0 |
| 38 | 39 | ||
| @@ -45,7 +46,8 @@ class Controller(): | @@ -45,7 +46,8 @@ class Controller(): | ||
| 45 | self.frame = frame | 46 | self.frame = frame |
| 46 | self.progress_dialog = None | 47 | self.progress_dialog = None |
| 47 | self.cancel_import = False | 48 | self.cancel_import = False |
| 48 | - | 49 | + #Init session |
| 50 | + session.Session() | ||
| 49 | 51 | ||
| 50 | def __bind_events(self): | 52 | def __bind_events(self): |
| 51 | ps.Publisher().subscribe(self.OnImportMedicalImages, 'Import directory') | 53 | ps.Publisher().subscribe(self.OnImportMedicalImages, 'Import directory') |
| @@ -271,11 +273,11 @@ class Controller(): | @@ -271,11 +273,11 @@ class Controller(): | ||
| 271 | prj.Project().name = filename | 273 | prj.Project().name = filename |
| 272 | prj.Project().path = filename | 274 | prj.Project().path = filename |
| 273 | prj.Project().SavePlistProject(dir_, filename) | 275 | prj.Project().SavePlistProject(dir_, filename) |
| 276 | + session.Session().project_status = const.SAVE_PROJECT | ||
| 274 | 277 | ||
| 275 | def OnOpenProject(self, pubsub_evt): | 278 | def OnOpenProject(self, pubsub_evt): |
| 276 | filename = os.path.abspath(pubsub_evt.data) | 279 | filename = os.path.abspath(pubsub_evt.data) |
| 277 | - | ||
| 278 | - | 280 | + session.Session().project_status = const.OPEN_PROJECT |
| 279 | proj = prj.Project() | 281 | proj = prj.Project() |
| 280 | proj.OpenPlistProject(filename) | 282 | proj.OpenPlistProject(filename) |
| 281 | proj.SetAcquisitionModality(proj.modality) | 283 | proj.SetAcquisitionModality(proj.modality) |
| @@ -285,5 +287,4 @@ class Controller(): | @@ -285,5 +287,4 @@ class Controller(): | ||
| 285 | const.THRESHOLD_INVALUE = proj.threshold_range[1] | 287 | const.THRESHOLD_INVALUE = proj.threshold_range[1] |
| 286 | const.WINDOW_LEVEL['Default'] = (proj.window, proj.level) | 288 | const.WINDOW_LEVEL['Default'] = (proj.window, proj.level) |
| 287 | const.WINDOW_LEVEL['Manual'] = (proj.window, proj.level) | 289 | const.WINDOW_LEVEL['Manual'] = (proj.window, proj.level) |
| 288 | - | ||
| 289 | - self.LoadProject() | 290 | + self.LoadProject() |
| 290 | \ No newline at end of file | 291 | \ No newline at end of file |
invesalius/data/slice_.py
| @@ -25,6 +25,7 @@ import constants as const | @@ -25,6 +25,7 @@ import constants as const | ||
| 25 | import imagedata_utils as iu | 25 | import imagedata_utils as iu |
| 26 | from mask import Mask | 26 | from mask import Mask |
| 27 | from project import Project | 27 | from project import Project |
| 28 | +import session | ||
| 28 | from utils import Singleton | 29 | from utils import Singleton |
| 29 | 30 | ||
| 30 | 31 | ||
| @@ -115,7 +116,10 @@ class Slice(object): | @@ -115,7 +116,10 @@ class Slice(object): | ||
| 115 | 116 | ||
| 116 | def __set_current_mask_threshold(self, evt_pubsub): | 117 | def __set_current_mask_threshold(self, evt_pubsub): |
| 117 | #FIXME: find a better way to implement this | 118 | #FIXME: find a better way to implement this |
| 118 | - if (self.num_gradient >= 2): | 119 | + print session.Session().project_status |
| 120 | + if (self.num_gradient >= 2) or \ | ||
| 121 | + (session.Session().project_status != const.OPEN_PROJECT): | ||
| 122 | + print "ENTROU........................................................" | ||
| 119 | threshold_range = evt_pubsub.data | 123 | threshold_range = evt_pubsub.data |
| 120 | index = self.current_mask.index | 124 | index = self.current_mask.index |
| 121 | self.SetMaskThreshold(index, threshold_range) | 125 | self.SetMaskThreshold(index, threshold_range) |
invesalius/project.py
invesalius/reader/dicom_reader.py
| @@ -32,6 +32,7 @@ import constants as const | @@ -32,6 +32,7 @@ import constants as const | ||
| 32 | import dicom | 32 | import dicom |
| 33 | import dicom_grouper | 33 | import dicom_grouper |
| 34 | import data.imagedata_utils as iu | 34 | import data.imagedata_utils as iu |
| 35 | +import session | ||
| 35 | 36 | ||
| 36 | def ReadDicomGroup(dir_): | 37 | def ReadDicomGroup(dir_): |
| 37 | 38 | ||
| @@ -40,6 +41,7 @@ def ReadDicomGroup(dir_): | @@ -40,6 +41,7 @@ def ReadDicomGroup(dir_): | ||
| 40 | filelist, dicom, zspacing = SelectLargerDicomGroup(patient_group) | 41 | filelist, dicom, zspacing = SelectLargerDicomGroup(patient_group) |
| 41 | filelist = SortFiles(filelist, dicom) | 42 | filelist = SortFiles(filelist, dicom) |
| 42 | imagedata = CreateImageData(filelist, zspacing) | 43 | imagedata = CreateImageData(filelist, zspacing) |
| 44 | + session.Session().project_status = const.NEW_PROJECT | ||
| 43 | return imagedata, dicom | 45 | return imagedata, dicom |
| 44 | else: | 46 | else: |
| 45 | return False | 47 | return False |