Commit 6c57dc4a94d97d74369b4dfa429d024d1be3d8ff

Authored by Paulo Henrique Junqueira Amorim
1 parent fff5ce91

ADD: Implemented progress gui in the importation frame

invesalius/control.py
  1 +import math
1 2 import os
2 3 import plistlib
3 4  
... ... @@ -23,6 +24,7 @@ class Controller():
23 24 self.volume = volume.Volume()
24 25 self.__bind_events()
25 26 self.frame = frame
  27 + self.progress_dialog = None
26 28  
27 29 def __bind_events(self):
28 30 ps.Publisher().subscribe(self.OnImportMedicalImages, 'Import directory')
... ... @@ -47,8 +49,13 @@ class Controller():
47 49 self.frame.Bind(reader.evt_end_load_file, self.LoadPanel)
48 50  
49 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 59 def LoadPanel(self,evt):
53 60 patient_series = evt.value
54 61 if patient_series:
... ...
invesalius/gui/dialogs.py
... ... @@ -59,10 +59,10 @@ def ShowNumberDialog(message, value=0):
59 59  
60 60  
61 61 class ProgressDialog(object):
62   - def __init__(self):
  62 + def __init__(self, maximum):
63 63 self.title = "InVesalius 3"
64 64 self.msg = "Loading DICOM files"
65   - self.maximum = 100
  65 + self.maximum = maximum
66 66 self.current = 0
67 67 self.style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL
68 68 self.dlg = wx.ProgressDialog(self.title,
... ... @@ -77,14 +77,10 @@ class ProgressDialog(object):
77 77 )
78 78  
79 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 82 return False
85   - elif (self.current > self.max):
86   - dlg.Destroy()
87   - return True
88 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 19 from vtk.util.colors import yellow
20 20 import glob
21 21 import os
  22 +import math
22 23  
23 24 import vtk
24 25 import vtkgdcm
... ... @@ -95,7 +96,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True):
95 96 parser = dicom.Parser()
96 97 counter += 1
97 98 if gui:
98   - yield counter/nfiles*100
  99 + yield (counter,nfiles)
99 100 if parser.SetFileName(filepath):
100 101 dcm = dicom.Dicom()
101 102 dcm.SetParser(parser)
... ... @@ -108,7 +109,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True):
108 109 parser = dicom.Parser()
109 110 counter += 1
110 111 if gui:
111   - yield counter/nfiles*100
  112 + yield (counter,nfiles)
112 113 if parser.SetFileName(filepath):
113 114 dcm = dicom.Dicom()
114 115 dcm.SetParser(parser)
... ... @@ -147,7 +148,7 @@ class ProgressDicomReader:
147 148 y = yGetDicomGroups(path, recursive)
148 149 while self.running:
149 150 value_progress = y.next()
150   - if isinstance(value_progress, float):
  151 + if isinstance(value_progress, tuple):
151 152 self.UpdateLoadFileProgress(value_progress)
152 153 else:
153 154 self.EndLoadFile(value_progress)
... ...