Commit 1702e940a84b7ef1d5378af4b7e67009c875bc8d
1 parent
31ee5fe5
Exists in
master
and in
68 other branches
STYLE: renamed some clut raycasting events to wx pattern and added some comments
Showing
2 changed files
with
28 additions
and
23 deletions
Show diff stats
invesalius/gui/default_viewers.py
@@ -28,8 +28,8 @@ import project | @@ -28,8 +28,8 @@ import project | ||
28 | import widgets.slice_menu as slice_menu_ | 28 | import widgets.slice_menu as slice_menu_ |
29 | 29 | ||
30 | from gui.widgets.clut_raycasting import CLUTRaycastingWidget, \ | 30 | from gui.widgets.clut_raycasting import CLUTRaycastingWidget, \ |
31 | - EVT_CLUT_POINT_CHANGED, EVT_CLUT_CURVE_SELECTED, \ | ||
32 | - EVT_CLUT_CHANGED_CURVE_WL | 31 | + EVT_CLUT_POINT_RELEASE, EVT_CLUT_CURVE_SELECT, \ |
32 | + EVT_CLUT_CURVE_WL_CHANGE | ||
33 | 33 | ||
34 | class Panel(wx.Panel): | 34 | class Panel(wx.Panel): |
35 | def __init__(self, parent): | 35 | def __init__(self, parent): |
@@ -223,9 +223,9 @@ class VolumeInteraction(wx.Panel): | @@ -223,9 +223,9 @@ class VolumeInteraction(wx.Panel): | ||
223 | self.aui_manager.Update() | 223 | self.aui_manager.Update() |
224 | 224 | ||
225 | def __bind_events_wx(self): | 225 | def __bind_events_wx(self): |
226 | - self.clut_raycasting.Bind(EVT_CLUT_POINT_CHANGED, self.OnPointChanged) | ||
227 | - self.clut_raycasting.Bind(EVT_CLUT_CURVE_SELECTED , self.OnCurveSelected) | ||
228 | - self.clut_raycasting.Bind(EVT_CLUT_CHANGED_CURVE_WL, | 226 | + self.clut_raycasting.Bind(EVT_CLUT_POINT_RELEASE, self.OnPointChanged) |
227 | + self.clut_raycasting.Bind(EVT_CLUT_CURVE_SELECT, self.OnCurveSelected) | ||
228 | + self.clut_raycasting.Bind(EVT_CLUT_CURVE_WL_CHANGE, | ||
229 | self.OnChangeCurveWL) | 229 | self.OnChangeCurveWL) |
230 | #self.Bind(wx.EVT_SIZE, self.OnSize) | 230 | #self.Bind(wx.EVT_SIZE, self.OnSize) |
231 | #self.Bind(wx.EVT_MAXIMIZE, self.OnMaximize) | 231 | #self.Bind(wx.EVT_MAXIMIZE, self.OnMaximize) |
invesalius/gui/widgets/clut_raycasting.py
@@ -31,6 +31,7 @@ class Node(object): | @@ -31,6 +31,7 @@ class Node(object): | ||
31 | self.graylevel = 0 | 31 | self.graylevel = 0 |
32 | self.opacity = 0 | 32 | self.opacity = 0 |
33 | 33 | ||
34 | + | ||
34 | class Curve(object): | 35 | class Curve(object): |
35 | """ | 36 | """ |
36 | Represents the curves in the raycasting preset. It contains the point nodes from | 37 | Represents the curves in the raycasting preset. It contains the point nodes from |
@@ -43,9 +44,13 @@ class Curve(object): | @@ -43,9 +44,13 @@ class Curve(object): | ||
43 | self.nodes = [] | 44 | self.nodes = [] |
44 | 45 | ||
45 | def CalculateWWWl(self): | 46 | def CalculateWWWl(self): |
47 | + """ | ||
48 | + Called when the curve width(ww) or position(wl) is modified. | ||
49 | + """ | ||
46 | self.ww = self.nodes[-1].graylevel - self.nodes[0].graylevel | 50 | self.ww = self.nodes[-1].graylevel - self.nodes[0].graylevel |
47 | self.wl = self.nodes[0].graylevel + self.ww / 2.0 | 51 | self.wl = self.nodes[0].graylevel + self.ww / 2.0 |
48 | 52 | ||
53 | + | ||
49 | class CLUTRaycastingWidget(wx.Panel): | 54 | class CLUTRaycastingWidget(wx.Panel): |
50 | """ | 55 | """ |
51 | This class represents the frame where images is showed | 56 | This class represents the frame where images is showed |
@@ -115,7 +120,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -115,7 +120,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
115 | self.dragged = True | 120 | self.dragged = True |
116 | self.previous_wl = x | 121 | self.previous_wl = x |
117 | self.curve_dragged = curve | 122 | self.curve_dragged = curve |
118 | - evt = CLUTEvent(myEVT_CLUT_CURVE_SELECTED, self.GetId(), curve) | 123 | + evt = CLUTEvent(myEVT_CLUT_CURVE_SELECT, self.GetId(), curve) |
119 | self.GetEventHandler().ProcessEvent(evt) | 124 | self.GetEventHandler().ProcessEvent(evt) |
120 | return | 125 | return |
121 | else: | 126 | else: |
@@ -137,7 +142,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -137,7 +142,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
137 | self.curves[n].nodes.insert(p, node) | 142 | self.curves[n].nodes.insert(p, node) |
138 | 143 | ||
139 | self.Refresh() | 144 | self.Refresh() |
140 | - nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), n) | 145 | + nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), n) |
141 | self.GetEventHandler().ProcessEvent(nevt) | 146 | self.GetEventHandler().ProcessEvent(nevt) |
142 | return | 147 | return |
143 | evt.Skip() | 148 | evt.Skip() |
@@ -158,7 +163,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -158,7 +163,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
158 | print self.curves[i].nodes | 163 | print self.curves[i].nodes |
159 | self.curves[i].nodes[j].colour = (r, g, b) | 164 | self.curves[i].nodes[j].colour = (r, g, b) |
160 | self.Refresh() | 165 | self.Refresh() |
161 | - nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), i) | 166 | + nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), i) |
162 | self.GetEventHandler().ProcessEvent(nevt) | 167 | self.GetEventHandler().ProcessEvent(nevt) |
163 | return | 168 | return |
164 | evt.Skip() | 169 | evt.Skip() |
@@ -173,7 +178,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -173,7 +178,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
173 | print "RightClick", i, j | 178 | print "RightClick", i, j |
174 | self.RemovePoint(i, j) | 179 | self.RemovePoint(i, j) |
175 | self.Refresh() | 180 | self.Refresh() |
176 | - nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), i) | 181 | + nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), i) |
177 | self.GetEventHandler().ProcessEvent(nevt) | 182 | self.GetEventHandler().ProcessEvent(nevt) |
178 | return | 183 | return |
179 | n_curve = self._has_clicked_in_selection_curve(evt.GetPositionTuple()) | 184 | n_curve = self._has_clicked_in_selection_curve(evt.GetPositionTuple()) |
@@ -181,7 +186,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -181,7 +186,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
181 | print "Removing a curve" | 186 | print "Removing a curve" |
182 | self.RemoveCurve(n_curve) | 187 | self.RemoveCurve(n_curve) |
183 | self.Refresh() | 188 | self.Refresh() |
184 | - nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), n_curve) | 189 | + nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), n_curve) |
185 | self.GetEventHandler().ProcessEvent(nevt) | 190 | self.GetEventHandler().ProcessEvent(nevt) |
186 | evt.Skip() | 191 | evt.Skip() |
187 | 192 | ||
@@ -191,7 +196,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -191,7 +196,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
191 | been occurred in the preset points. | 196 | been occurred in the preset points. |
192 | """ | 197 | """ |
193 | if self.to_render: | 198 | if self.to_render: |
194 | - evt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), 0) | 199 | + evt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), 0) |
195 | self.GetEventHandler().ProcessEvent(evt) | 200 | self.GetEventHandler().ProcessEvent(evt) |
196 | self.dragged = False | 201 | self.dragged = False |
197 | self.curve_dragged = None | 202 | self.curve_dragged = None |
@@ -257,7 +262,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -257,7 +262,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
257 | self.Refresh() | 262 | self.Refresh() |
258 | 263 | ||
259 | # A point in the preset has been changed, raising a event | 264 | # A point in the preset has been changed, raising a event |
260 | - evt = CLUTEvent(myEVT_CLUT_POINT , self.GetId(), i) | 265 | + evt = CLUTEvent(myEVT_CLUT_POINT_MOVE , self.GetId(), i) |
261 | self.GetEventHandler().ProcessEvent(evt) | 266 | self.GetEventHandler().ProcessEvent(evt) |
262 | 267 | ||
263 | elif self.dragged and self.curve_dragged is not None: | 268 | elif self.dragged and self.curve_dragged is not None: |
@@ -269,7 +274,7 @@ class CLUTRaycastingWidget(wx.Panel): | @@ -269,7 +274,7 @@ class CLUTRaycastingWidget(wx.Panel): | ||
269 | node.graylevel = self.PixelToHounsfield(node.x) | 274 | node.graylevel = self.PixelToHounsfield(node.x) |
270 | 275 | ||
271 | # The window level has been changed, raising a event! | 276 | # The window level has been changed, raising a event! |
272 | - evt = CLUTEvent(myEVT_CLUT_CHANGED_CURVE_WL, self.GetId(), | 277 | + evt = CLUTEvent(myEVT_CLUT_CURVE_WL_CHANGE, self.GetId(), |
273 | self.curve_dragged) | 278 | self.curve_dragged) |
274 | self.GetEventHandler().ProcessEvent(evt) | 279 | self.GetEventHandler().ProcessEvent(evt) |
275 | 280 | ||
@@ -641,21 +646,21 @@ myEVT_CLUT_SLIDER = wx.NewEventType() | @@ -641,21 +646,21 @@ myEVT_CLUT_SLIDER = wx.NewEventType() | ||
641 | EVT_CLUT_SLIDER = wx.PyEventBinder(myEVT_CLUT_SLIDER, 1) | 646 | EVT_CLUT_SLIDER = wx.PyEventBinder(myEVT_CLUT_SLIDER, 1) |
642 | 647 | ||
643 | # Occurs when CLUT was slided | 648 | # Occurs when CLUT was slided |
644 | -myEVT_CLUT_SLIDER_CHANGED = wx.NewEventType() | ||
645 | -EVT_CLUT_SLIDER_CHANGED = wx.PyEventBinder(myEVT_CLUT_SLIDER_CHANGED, 1) | 649 | +myEVT_CLUT_SLIDER_CHANGE = wx.NewEventType() |
650 | +EVT_CLUT_SLIDER_CHANGE = wx.PyEventBinder(myEVT_CLUT_SLIDER_CHANGE, 1) | ||
646 | 651 | ||
647 | # Occurs when CLUT point is changing | 652 | # Occurs when CLUT point is changing |
648 | -myEVT_CLUT_POINT = wx.NewEventType() | ||
649 | -EVT_CLUT_POINT = wx.PyEventBinder(myEVT_CLUT_POINT, 1) | 653 | +myEVT_CLUT_POINT_MOVE = wx.NewEventType() |
654 | +EVT_CLUT_POINT_MOVE = wx.PyEventBinder(myEVT_CLUT_POINT_MOVE, 1) | ||
650 | 655 | ||
651 | # Occurs when a CLUT point was changed | 656 | # Occurs when a CLUT point was changed |
652 | -myEVT_CLUT_POINT_CHANGED = wx.NewEventType() | ||
653 | -EVT_CLUT_POINT_CHANGED = wx.PyEventBinder(myEVT_CLUT_POINT_CHANGED, 1) | 657 | +myEVT_CLUT_POINT_RELEASE = wx.NewEventType() |
658 | +EVT_CLUT_POINT_RELEASE = wx.PyEventBinder(myEVT_CLUT_POINT_RELEASE, 1) | ||
654 | 659 | ||
655 | # Selected a curve | 660 | # Selected a curve |
656 | -myEVT_CLUT_CURVE_SELECTED = wx.NewEventType() | ||
657 | -EVT_CLUT_CURVE_SELECTED = wx.PyEventBinder(myEVT_CLUT_CURVE_SELECTED, 1) | 661 | +myEVT_CLUT_CURVE_SELECT = wx.NewEventType() |
662 | +EVT_CLUT_CURVE_SELECT = wx.PyEventBinder(myEVT_CLUT_CURVE_SELECT, 1) | ||
658 | 663 | ||
659 | # Changed the wl from a curve | 664 | # Changed the wl from a curve |
660 | -myEVT_CLUT_CHANGED_CURVE_WL = wx.NewEventType() | ||
661 | -EVT_CLUT_CHANGED_CURVE_WL = wx.PyEventBinder(myEVT_CLUT_CHANGED_CURVE_WL, 1) | 665 | +myEVT_CLUT_CURVE_WL_CHANGE = wx.NewEventType() |
666 | +EVT_CLUT_CURVE_WL_CHANGE = wx.PyEventBinder(myEVT_CLUT_CURVE_WL_CHANGE, 1) |