Commit 662885453aff81eeef12566e4193dc75fde5d279
1 parent
d6f91a4b
Exists in
master
and in
6 other branches
ADD: Import panel (first version - very simple and without functionality)
Showing
2 changed files
with
158 additions
and
0 deletions
Show diff stats
.gitattributes
... | ... | @@ -91,6 +91,7 @@ invesalius/gui/default_tasks.py -text |
91 | 91 | invesalius/gui/default_viewers.py -text |
92 | 92 | invesalius/gui/frame.py -text |
93 | 93 | invesalius/gui/import_data_wizard.py -text |
94 | +invesalius/gui/import_panel.py -text | |
94 | 95 | invesalius/gui/task_exporter.py -text |
95 | 96 | invesalius/gui/task_generic.py -text |
96 | 97 | invesalius/gui/task_importer.py -text | ... | ... |
... | ... | @@ -0,0 +1,157 @@ |
1 | +import wx | |
2 | +import wx.gizmos as gizmos | |
3 | +import wx.lib.pubsub as ps | |
4 | +import wx.lib.splitter as spl | |
5 | + | |
6 | +class Panel(wx.Panel): | |
7 | + def __init__(self, parent): | |
8 | + wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), | |
9 | + size=wx.Size(280, 656)) | |
10 | + | |
11 | + sizer = wx.BoxSizer(wx.VERTICAL) | |
12 | + sizer.Add(InnerPanel(self), 1, wx.EXPAND|wx.GROW|wx.ALL, 5) | |
13 | + self.SetSizer(sizer) | |
14 | + | |
15 | +# Inner fold panel | |
16 | +class InnerPanel(wx.Panel): | |
17 | + def __init__(self, parent): | |
18 | + wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), | |
19 | + size=wx.Size(680, 656)) | |
20 | + | |
21 | + splitter = spl.MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) | |
22 | + splitter.SetOrientation(wx.VERTICAL) | |
23 | + self.splitter = splitter | |
24 | + | |
25 | + sizer = wx.BoxSizer(wx.VERTICAL) | |
26 | + sizer.Add(splitter, 1, wx.EXPAND) | |
27 | + self.SetSizer(sizer) | |
28 | + | |
29 | + self.text_panel = TextPanel(splitter) | |
30 | + splitter.AppendWindow(self.text_panel, 250) | |
31 | + | |
32 | + self.image_panel = ImagePanel(splitter) | |
33 | + splitter.AppendWindow(self.image_panel, 250) | |
34 | + | |
35 | + self.__bind_evt() | |
36 | + | |
37 | + def __bind_evt(self): | |
38 | + ps.Publisher().subscribe(self.ShowDicomPreview, "Load import panel") | |
39 | + | |
40 | + def ShowDicomPreview(self, pubsub_evt): | |
41 | + dict = pubsub_evt.data | |
42 | + self.text_panel.Populate(dict) | |
43 | + | |
44 | + | |
45 | +class TextPanel(wx.Panel): | |
46 | + def __init__(self, parent): | |
47 | + wx.Panel.__init__(self, parent, -1) | |
48 | + self.SetBackgroundColour((255,0,0)) | |
49 | + self.Bind(wx.EVT_SIZE, self.OnSize) | |
50 | + | |
51 | + | |
52 | + self.tree = gizmos.TreeListCtrl(self, -1, style = | |
53 | + wx.TR_DEFAULT_STYLE | |
54 | + | wx.TR_HIDE_ROOT | |
55 | + | wx.TR_ROW_LINES | |
56 | + | wx.TR_COLUMN_LINES | |
57 | + | wx.TR_FULL_ROW_HIGHLIGHT | |
58 | + | wx.TR_FULL_ROW_HIGHLIGHT | |
59 | + ) | |
60 | + | |
61 | + | |
62 | + self.tree.AddColumn("Patient name") | |
63 | + self.tree.AddColumn("Patient ID") | |
64 | + self.tree.AddColumn("Age") | |
65 | + self.tree.AddColumn("Study description") | |
66 | + self.tree.AddColumn("Modality") | |
67 | + self.tree.AddColumn("Date acquired") | |
68 | + self.tree.AddColumn("# Images") | |
69 | + self.tree.AddColumn("Institution") | |
70 | + self.tree.AddColumn("Date of birth") | |
71 | + self.tree.AddColumn("Accession Number") | |
72 | + self.tree.AddColumn("Referring physician") | |
73 | + self.tree.AddColumn("Performing") | |
74 | + | |
75 | + self.tree.SetMainColumn(0) # the one with the tree in it... | |
76 | + self.tree.SetColumnWidth(0, 250) # ok | |
77 | + self.tree.SetColumnWidth(1, 80) # ok | |
78 | + self.tree.SetColumnWidth(2, 40) # ok | |
79 | + self.tree.SetColumnWidth(3, 160) # ok | |
80 | + self.tree.SetColumnWidth(4, 80) # ok | |
81 | + self.tree.SetColumnWidth(5, 110) | |
82 | + self.tree.SetColumnWidth(6, 70) | |
83 | + self.tree.SetColumnWidth(7, 90) | |
84 | + self.tree.SetColumnWidth(8, 130) | |
85 | + self.tree.SetColumnWidth(9, 240) | |
86 | + self.tree.SetColumnWidth(10, 120) | |
87 | + | |
88 | + | |
89 | + self.root = self.tree.AddRoot("InVesalius Database") | |
90 | + | |
91 | + def Populate(self, dict): | |
92 | + | |
93 | + for i in xrange(4): | |
94 | + txt = "Name %d" % i | |
95 | + child = self.tree.AppendItem(self.root, txt) | |
96 | + if i%2: | |
97 | + self.tree.SetItemBackgroundColour(child, (242,246,254)) | |
98 | + self.tree.SetItemText(child, txt, 1) | |
99 | + self.tree.SetItemText(child, "age", 2) | |
100 | + | |
101 | + for j in xrange(4): | |
102 | + txt = "Series name %d" % i | |
103 | + child2 = self.tree.AppendItem(child, txt) | |
104 | + if j%2: | |
105 | + self.tree.SetItemBackgroundColour(child2, (242,246,254)) | |
106 | + self.tree.SetItemText(child2, txt, 1) | |
107 | + self.tree.SetItemText(child2, txt, 2) | |
108 | + | |
109 | + | |
110 | + self.tree.Expand(self.root) | |
111 | + | |
112 | + self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) | |
113 | + self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) | |
114 | + | |
115 | + | |
116 | + def OnActivate(self, evt): | |
117 | + print 'OnActivate: %s' % self.tree.GetItemText(evt.GetItem()) | |
118 | + | |
119 | + | |
120 | + def OnRightUp(self, evt): | |
121 | + pos = evt.GetPosition() | |
122 | + item, flags, col = self.tree.HitTest(pos) | |
123 | + if item: | |
124 | + print 'Flags: %s, Col:%s, Text: %s' %\ | |
125 | + (flags, col, self.tree.GetItemText(item, col)) | |
126 | + | |
127 | + def OnSize(self, evt): | |
128 | + self.tree.SetSize(self.GetSize()) | |
129 | + | |
130 | +class ImagePanel(wx.Panel): | |
131 | + def __init__(self, parent): | |
132 | + wx.Panel.__init__(self, parent, -1) | |
133 | + self.SetBackgroundColour((0,255,0)) | |
134 | + | |
135 | + splitter = spl.MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) | |
136 | + splitter.SetOrientation(wx.HORIZONTAL) | |
137 | + self.splitter = splitter | |
138 | + | |
139 | + sizer = wx.BoxSizer(wx.HORIZONTAL) | |
140 | + sizer.Add(splitter, 1, wx.EXPAND) | |
141 | + self.SetSizer(sizer) | |
142 | + | |
143 | + self.text_panel = SeriesPanel(splitter) | |
144 | + splitter.AppendWindow(self.text_panel, 400) | |
145 | + | |
146 | + self.image_panel = SlicePanel(splitter) | |
147 | + splitter.AppendWindow(self.image_panel, 250) | |
148 | + | |
149 | +class SeriesPanel(wx.Panel): | |
150 | + def __init__(self, parent): | |
151 | + wx.Panel.__init__(self, parent, -1) | |
152 | + self.SetBackgroundColour((255,255,255)) | |
153 | + | |
154 | +class SlicePanel(wx.Panel): | |
155 | + def __init__(self, parent): | |
156 | + wx.Panel.__init__(self, parent, -1) | |
157 | + self.SetBackgroundColour((0,0,0)) | |
0 | 158 | \ No newline at end of file | ... | ... |