Commit 6c57dc4a94d97d74369b4dfa429d024d1be3d8ff
1 parent
fff5ce91
Exists in
master
and in
6 other branches
ADD: Implemented progress gui in the importation frame
Showing
3 changed files
with
20 additions
and
16 deletions
Show diff stats
invesalius/control.py
1 | +import math | ||
1 | import os | 2 | import os |
2 | import plistlib | 3 | import plistlib |
3 | 4 | ||
@@ -23,6 +24,7 @@ class Controller(): | @@ -23,6 +24,7 @@ class Controller(): | ||
23 | self.volume = volume.Volume() | 24 | self.volume = volume.Volume() |
24 | self.__bind_events() | 25 | self.__bind_events() |
25 | self.frame = frame | 26 | self.frame = frame |
27 | + self.progress_dialog = None | ||
26 | 28 | ||
27 | def __bind_events(self): | 29 | def __bind_events(self): |
28 | ps.Publisher().subscribe(self.OnImportMedicalImages, 'Import directory') | 30 | ps.Publisher().subscribe(self.OnImportMedicalImages, 'Import directory') |
@@ -47,8 +49,13 @@ class Controller(): | @@ -47,8 +49,13 @@ class Controller(): | ||
47 | self.frame.Bind(reader.evt_end_load_file, self.LoadPanel) | 49 | self.frame.Bind(reader.evt_end_load_file, self.LoadPanel) |
48 | 50 | ||
49 | def Progress(self, evt): | 51 | def Progress(self, evt): |
50 | - print evt.progress | ||
51 | - | 52 | + if not(self.progress_dialog): |
53 | + self.progress_dialog = dialog.ProgressDialog(maximum = evt.progress[1]) | ||
54 | + else: | ||
55 | + if not(self.progress_dialog.Update(evt.progress[0])): | ||
56 | + self.progress_dialog = None | ||
57 | + | ||
58 | + | ||
52 | def LoadPanel(self,evt): | 59 | def LoadPanel(self,evt): |
53 | patient_series = evt.value | 60 | patient_series = evt.value |
54 | if patient_series: | 61 | if patient_series: |
invesalius/gui/dialogs.py
@@ -59,10 +59,10 @@ def ShowNumberDialog(message, value=0): | @@ -59,10 +59,10 @@ def ShowNumberDialog(message, value=0): | ||
59 | 59 | ||
60 | 60 | ||
61 | class ProgressDialog(object): | 61 | class ProgressDialog(object): |
62 | - def __init__(self): | 62 | + def __init__(self, maximum): |
63 | self.title = "InVesalius 3" | 63 | self.title = "InVesalius 3" |
64 | self.msg = "Loading DICOM files" | 64 | self.msg = "Loading DICOM files" |
65 | - self.maximum = 100 | 65 | + self.maximum = maximum |
66 | self.current = 0 | 66 | self.current = 0 |
67 | self.style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL | 67 | self.style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL |
68 | self.dlg = wx.ProgressDialog(self.title, | 68 | self.dlg = wx.ProgressDialog(self.title, |
@@ -77,14 +77,10 @@ class ProgressDialog(object): | @@ -77,14 +77,10 @@ class ProgressDialog(object): | ||
77 | ) | 77 | ) |
78 | 78 | ||
79 | def Update(self, value): | 79 | def Update(self, value): |
80 | - self.current += value | ||
81 | - (keep_going, skip) = dlg.Update(count) | ||
82 | - if (not keep_going) or (skip): | ||
83 | - dlg.Destroy() | 80 | + if (value == self.maximum): |
81 | + self.dlg.Destroy() | ||
84 | return False | 82 | return False |
85 | - elif (self.current > self.max): | ||
86 | - dlg.Destroy() | ||
87 | - return True | ||
88 | else: | 83 | else: |
89 | - return self.current | ||
90 | - | 84 | + self.dlg.Update(value) |
85 | + return True | ||
86 | + |
invesalius/reader/dicom_reader.py
@@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
19 | from vtk.util.colors import yellow | 19 | from vtk.util.colors import yellow |
20 | import glob | 20 | import glob |
21 | import os | 21 | import os |
22 | +import math | ||
22 | 23 | ||
23 | import vtk | 24 | import vtk |
24 | import vtkgdcm | 25 | import vtkgdcm |
@@ -95,7 +96,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | @@ -95,7 +96,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | ||
95 | parser = dicom.Parser() | 96 | parser = dicom.Parser() |
96 | counter += 1 | 97 | counter += 1 |
97 | if gui: | 98 | if gui: |
98 | - yield counter/nfiles*100 | 99 | + yield (counter,nfiles) |
99 | if parser.SetFileName(filepath): | 100 | if parser.SetFileName(filepath): |
100 | dcm = dicom.Dicom() | 101 | dcm = dicom.Dicom() |
101 | dcm.SetParser(parser) | 102 | dcm.SetParser(parser) |
@@ -108,7 +109,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | @@ -108,7 +109,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | ||
108 | parser = dicom.Parser() | 109 | parser = dicom.Parser() |
109 | counter += 1 | 110 | counter += 1 |
110 | if gui: | 111 | if gui: |
111 | - yield counter/nfiles*100 | 112 | + yield (counter,nfiles) |
112 | if parser.SetFileName(filepath): | 113 | if parser.SetFileName(filepath): |
113 | dcm = dicom.Dicom() | 114 | dcm = dicom.Dicom() |
114 | dcm.SetParser(parser) | 115 | dcm.SetParser(parser) |
@@ -147,7 +148,7 @@ class ProgressDicomReader: | @@ -147,7 +148,7 @@ class ProgressDicomReader: | ||
147 | y = yGetDicomGroups(path, recursive) | 148 | y = yGetDicomGroups(path, recursive) |
148 | while self.running: | 149 | while self.running: |
149 | value_progress = y.next() | 150 | value_progress = y.next() |
150 | - if isinstance(value_progress, float): | 151 | + if isinstance(value_progress, tuple): |
151 | self.UpdateLoadFileProgress(value_progress) | 152 | self.UpdateLoadFileProgress(value_progress) |
152 | else: | 153 | else: |
153 | self.EndLoadFile(value_progress) | 154 | self.EndLoadFile(value_progress) |