Commit 1702e940a84b7ef1d5378af4b7e67009c875bc8d

Authored by tfmoraes
1 parent 31ee5fe5

STYLE: renamed some clut raycasting events to wx pattern and added some comments

invesalius/gui/default_viewers.py
... ... @@ -28,8 +28,8 @@ import project
28 28 import widgets.slice_menu as slice_menu_
29 29  
30 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 34 class Panel(wx.Panel):
35 35 def __init__(self, parent):
... ... @@ -223,9 +223,9 @@ class VolumeInteraction(wx.Panel):
223 223 self.aui_manager.Update()
224 224  
225 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 229 self.OnChangeCurveWL)
230 230 #self.Bind(wx.EVT_SIZE, self.OnSize)
231 231 #self.Bind(wx.EVT_MAXIMIZE, self.OnMaximize)
... ...
invesalius/gui/widgets/clut_raycasting.py
... ... @@ -31,6 +31,7 @@ class Node(object):
31 31 self.graylevel = 0
32 32 self.opacity = 0
33 33  
  34 +
34 35 class Curve(object):
35 36 """
36 37 Represents the curves in the raycasting preset. It contains the point nodes from
... ... @@ -43,9 +44,13 @@ class Curve(object):
43 44 self.nodes = []
44 45  
45 46 def CalculateWWWl(self):
  47 + """
  48 + Called when the curve width(ww) or position(wl) is modified.
  49 + """
46 50 self.ww = self.nodes[-1].graylevel - self.nodes[0].graylevel
47 51 self.wl = self.nodes[0].graylevel + self.ww / 2.0
48 52  
  53 +
49 54 class CLUTRaycastingWidget(wx.Panel):
50 55 """
51 56 This class represents the frame where images is showed
... ... @@ -115,7 +120,7 @@ class CLUTRaycastingWidget(wx.Panel):
115 120 self.dragged = True
116 121 self.previous_wl = x
117 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 124 self.GetEventHandler().ProcessEvent(evt)
120 125 return
121 126 else:
... ... @@ -137,7 +142,7 @@ class CLUTRaycastingWidget(wx.Panel):
137 142 self.curves[n].nodes.insert(p, node)
138 143  
139 144 self.Refresh()
140   - nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), n)
  145 + nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), n)
141 146 self.GetEventHandler().ProcessEvent(nevt)
142 147 return
143 148 evt.Skip()
... ... @@ -158,7 +163,7 @@ class CLUTRaycastingWidget(wx.Panel):
158 163 print self.curves[i].nodes
159 164 self.curves[i].nodes[j].colour = (r, g, b)
160 165 self.Refresh()
161   - nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), i)
  166 + nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), i)
162 167 self.GetEventHandler().ProcessEvent(nevt)
163 168 return
164 169 evt.Skip()
... ... @@ -173,7 +178,7 @@ class CLUTRaycastingWidget(wx.Panel):
173 178 print "RightClick", i, j
174 179 self.RemovePoint(i, j)
175 180 self.Refresh()
176   - nevt = CLUTEvent(myEVT_CLUT_POINT_CHANGED, self.GetId(), i)
  181 + nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), i)
177 182 self.GetEventHandler().ProcessEvent(nevt)
178 183 return
179 184 n_curve = self._has_clicked_in_selection_curve(evt.GetPositionTuple())
... ... @@ -181,7 +186,7 @@ class CLUTRaycastingWidget(wx.Panel):
181 186 print "Removing a curve"
182 187 self.RemoveCurve(n_curve)
183 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 190 self.GetEventHandler().ProcessEvent(nevt)
186 191 evt.Skip()
187 192  
... ... @@ -191,7 +196,7 @@ class CLUTRaycastingWidget(wx.Panel):
191 196 been occurred in the preset points.
192 197 """
193 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 200 self.GetEventHandler().ProcessEvent(evt)
196 201 self.dragged = False
197 202 self.curve_dragged = None
... ... @@ -257,7 +262,7 @@ class CLUTRaycastingWidget(wx.Panel):
257 262 self.Refresh()
258 263  
259 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 266 self.GetEventHandler().ProcessEvent(evt)
262 267  
263 268 elif self.dragged and self.curve_dragged is not None:
... ... @@ -269,7 +274,7 @@ class CLUTRaycastingWidget(wx.Panel):
269 274 node.graylevel = self.PixelToHounsfield(node.x)
270 275  
271 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 278 self.curve_dragged)
274 279 self.GetEventHandler().ProcessEvent(evt)
275 280  
... ... @@ -641,21 +646,21 @@ myEVT_CLUT_SLIDER = wx.NewEventType()
641 646 EVT_CLUT_SLIDER = wx.PyEventBinder(myEVT_CLUT_SLIDER, 1)
642 647  
643 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 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 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 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 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)
... ...