Commit 83a118b3022ebcd93cd1822d973713e2f6d6310e
1 parent
081d3815
Exists in
master
and in
68 other branches
FIX: Using device context(dc) instead of static bitmap to show dicom previews
Showing
1 changed file
with
24 additions
and
3 deletions
Show diff stats
invesalius/gui/dicom_preview_panel.py
... | ... | @@ -97,6 +97,26 @@ class DicomInfo(object): |
97 | 97 | return self._preview |
98 | 98 | |
99 | 99 | |
100 | +class DicomPaintPanel(wx.Panel): | |
101 | + def __init__(self, parent): | |
102 | + super(DicomPaintPanel, self).__init__(parent) | |
103 | + self._bind_events() | |
104 | + self.image = None | |
105 | + | |
106 | + def _bind_events(self): | |
107 | + self.Bind(wx.EVT_PAINT, self.OnPaint) | |
108 | + | |
109 | + def SetImage(self, image): | |
110 | + self.image = image | |
111 | + | |
112 | + def OnPaint(self, evt): | |
113 | + if self.image: | |
114 | + dc = wx.AutoBufferedPaintDC(self) | |
115 | + dc.Clear() | |
116 | + dc.DrawBitmap(self.image, 0, 0) | |
117 | + | |
118 | + | |
119 | + | |
100 | 120 | class Preview(wx.Panel): |
101 | 121 | """ |
102 | 122 | The little previews. |
... | ... | @@ -114,7 +134,7 @@ class Preview(wx.Panel): |
114 | 134 | |
115 | 135 | self.title = wx.StaticText(self, -1, _("Image")) |
116 | 136 | self.subtitle = wx.StaticText(self, -1, _("Image")) |
117 | - self.image_viewer = wx.StaticBitmap(self, -1) | |
137 | + self.image_viewer = DicomPaintPanel(self) | |
118 | 138 | |
119 | 139 | self.sizer = wx.BoxSizer(wx.VERTICAL) |
120 | 140 | self.sizer.Add(self.title, 0, |
... | ... | @@ -169,7 +189,7 @@ class Preview(wx.Panel): |
169 | 189 | self.ID = dicom_info.id |
170 | 190 | dicom_info.size = self.image_viewer.GetSize() |
171 | 191 | image = dicom_info.preview |
172 | - self.image_viewer.SetBitmap(image) | |
192 | + self.image_viewer.SetImage(image) | |
173 | 193 | self.data = dicom_info.id |
174 | 194 | self.select_on = dicom_info.selected |
175 | 195 | self.Select() |
... | ... | @@ -184,7 +204,8 @@ class Preview(wx.Panel): |
184 | 204 | def OnEnter(self, evt): |
185 | 205 | if not self.select_on: |
186 | 206 | #c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DHILIGHT) |
187 | - c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT) | |
207 | + c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) | |
208 | + print c | |
188 | 209 | self.SetBackgroundColour(c) |
189 | 210 | |
190 | 211 | def OnLeave(self, evt): | ... | ... |