Commit 99ace3657104bd1793b7d0b35f4e2e9323902e6f
1 parent
d1963727
Exists in
master
and in
6 other branches
STYLE: Cosmetical changes:
* Using underscore (_) instead of CamelCase to methods and variables * Removed duplicated blank lines * Lines smaller than 69 * space after commas
Showing
1 changed file
with
44 additions
and
34 deletions
Show diff stats
invesalius/data/viewer_slice.py
... | ... | @@ -37,12 +37,14 @@ class Viewer(wx.Panel): |
37 | 37 | colour = [255*c for c in const.ORIENTATION_COLOUR[orientation]] |
38 | 38 | self.SetBackgroundColour(colour) |
39 | 39 | |
40 | - # Interactor aditional style | |
40 | + # Interactor additional style | |
41 | 41 | self.modes = []#['DEFAULT'] |
42 | 42 | self.mouse_pressed = 0 |
43 | 43 | |
44 | 44 | # All renderers and image actors in this viewer |
45 | 45 | self.image_windows = [] |
46 | + # The layout from image_window, the first is number of cols, the second | |
47 | + # is the number of rows | |
46 | 48 | self.layout = (2, 2) |
47 | 49 | |
48 | 50 | self.__init_gui() |
... | ... | @@ -95,7 +97,7 @@ class Viewer(wx.Panel): |
95 | 97 | self.ren = ren |
96 | 98 | |
97 | 99 | |
98 | - def AppendMode(self, mode): | |
100 | + def append_mode(self, mode): | |
99 | 101 | |
100 | 102 | # Retrieve currently set modes |
101 | 103 | self.modes.append(mode) |
... | ... | @@ -159,7 +161,7 @@ class Viewer(wx.Panel): |
159 | 161 | cursor = ca.CursorCircle() |
160 | 162 | self.cursor = cursor |
161 | 163 | |
162 | - cursor.SetOrientation(self.orientation) | |
164 | + cursor.set_orientation(self.orientation) | |
163 | 165 | coordinates = {"SAGITAL": [self.slice_number, 0, 0], |
164 | 166 | "CORONAL": [0, self.slice_number, 0], |
165 | 167 | "AXIAL": [0, 0, self.slice_number]} |
... | ... | @@ -187,9 +189,10 @@ class Viewer(wx.Panel): |
187 | 189 | image_window = self.get_image_window(render) |
188 | 190 | self.pick.Pick(mouse_x, mouse_y, 0, render) |
189 | 191 | |
190 | - coord = self.GetCoordinateCursor() | |
192 | + coord = self.get_coordinate_cursor() | |
191 | 193 | self.cursor.SetPosition(coord) |
192 | - self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition(image_window)) | |
194 | + self.cursor.SetEditionPosition( | |
195 | + self.get_coordinate_cursor_edition(image_window)) | |
193 | 196 | self.__update_cursor_position(coord) |
194 | 197 | #render.Render() |
195 | 198 | |
... | ... | @@ -198,7 +201,7 @@ class Viewer(wx.Panel): |
198 | 201 | const.BRUSH_THRESH: 'Edit mask pixel'} |
199 | 202 | msg = evt_msg[self._brush_cursor_op] |
200 | 203 | |
201 | - pixels = itertools.ifilter(self.TestOperationPosition, | |
204 | + pixels = itertools.ifilter(self.test_operation_position, | |
202 | 205 | self.cursor.GetPixels()) |
203 | 206 | ps.Publisher().sendMessage(msg, pixels) |
204 | 207 | |
... | ... | @@ -212,9 +215,10 @@ class Viewer(wx.Panel): |
212 | 215 | render = self.interactor.FindPokedRenderer(mouse_x, mouse_y) |
213 | 216 | image_window = self.get_image_window(render) |
214 | 217 | self.pick.Pick(mouse_x, mouse_y, 0, render) |
215 | - coord = self.GetCoordinateCursor() | |
218 | + coord = self.get_coordinate_cursor() | |
216 | 219 | self.cursor.SetPosition(coord) |
217 | - self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition(image_window)) | |
220 | + self.cursor.SetEditionPosition( | |
221 | + self.get_coordinate_cursor_edition(image_window)) | |
218 | 222 | self.__update_cursor_position(coord) |
219 | 223 | |
220 | 224 | if self._brush_cursor_op == const.BRUSH_ERASE: |
... | ... | @@ -225,7 +229,7 @@ class Viewer(wx.Panel): |
225 | 229 | evt_msg = 'Edit mask pixel' |
226 | 230 | |
227 | 231 | if self.mouse_pressed: |
228 | - pixels = itertools.ifilter(self.TestOperationPosition, | |
232 | + pixels = itertools.ifilter(self.test_operation_position, | |
229 | 233 | self.cursor.GetPixels()) |
230 | 234 | ps.Publisher().sendMessage(evt_msg, pixels) |
231 | 235 | ps.Publisher().sendMessage('Update slice viewer') |
... | ... | @@ -233,7 +237,7 @@ class Viewer(wx.Panel): |
233 | 237 | self.interactor.Render() |
234 | 238 | |
235 | 239 | def OnCrossMove(self, obj, evt_vtk): |
236 | - coord = self.GetCoordinate() | |
240 | + coord = self.get_coordinate() | |
237 | 241 | # Update position in other slices |
238 | 242 | if self.mouse_pressed: |
239 | 243 | ps.Publisher().sendMessage('Update cursor position in slice', |
... | ... | @@ -250,7 +254,7 @@ class Viewer(wx.Panel): |
250 | 254 | if i[0] is render: |
251 | 255 | return i |
252 | 256 | |
253 | - def GetCoordinate(self): | |
257 | + def get_coordinate(self): | |
254 | 258 | # Find position |
255 | 259 | x, y, z = self.pick.GetPickPosition() |
256 | 260 | |
... | ... | @@ -288,12 +292,12 @@ class Viewer(wx.Panel): |
288 | 292 | |
289 | 293 | return coord |
290 | 294 | |
291 | - def GetCoordinateCursor(self): | |
295 | + def get_coordinate_cursor(self): | |
292 | 296 | # Find position |
293 | 297 | x, y, z = self.pick.GetPickPosition() |
294 | 298 | return x, y, z |
295 | 299 | |
296 | - def GetCoordinateCursorEdition(self, image_window): | |
300 | + def get_coordinate_cursor_edition(self, image_window): | |
297 | 301 | # Find position |
298 | 302 | actor, slice_number = image_window[1::] |
299 | 303 | x, y, z = self.pick.GetPickPosition() |
... | ... | @@ -305,7 +309,7 @@ class Viewer(wx.Panel): |
305 | 309 | y = float(y - bound_yi) |
306 | 310 | z = float(z - bound_zi) |
307 | 311 | |
308 | - dx = bound_xf - bound_xi; | |
312 | + dx = bound_xf - bound_xi | |
309 | 313 | dy = bound_yf - bound_yi |
310 | 314 | dz = bound_zf - bound_zi |
311 | 315 | |
... | ... | @@ -324,21 +328,27 @@ class Viewer(wx.Panel): |
324 | 328 | except ZeroDivisionError: |
325 | 329 | z = slice_number |
326 | 330 | |
327 | - return x,y,z | |
331 | + return x, y, z | |
328 | 332 | |
329 | 333 | def __bind_events(self): |
330 | - ps.Publisher().subscribe(self.LoadImagedata, 'Load slice to viewer') | |
331 | - ps.Publisher().subscribe(self.SetBrushColour, 'Change mask colour') | |
332 | - ps.Publisher().subscribe(self.UpdateRender, 'Update slice viewer') | |
333 | - ps.Publisher().subscribe(self.ChangeSliceNumber, ('Set scroll position', | |
334 | - self.orientation)) | |
335 | - | |
334 | + ps.Publisher().subscribe(self.LoadImagedata, | |
335 | + 'Load slice to viewer') | |
336 | + ps.Publisher().subscribe(self.SetBrushColour, | |
337 | + 'Change mask colour') | |
338 | + ps.Publisher().subscribe(self.UpdateRender, | |
339 | + 'Update slice viewer') | |
340 | + ps.Publisher().subscribe(self.ChangeSliceNumber, | |
341 | + ('Set scroll position', | |
342 | + self.orientation)) | |
336 | 343 | ### |
337 | - ps.Publisher().subscribe(self.ChangeBrushSize,'Set edition brush size') | |
338 | - ps.Publisher().subscribe(self.ChangeBrushColour, 'Add mask') | |
339 | - ps.Publisher().subscribe(self.ChangeBrushActor, 'Set brush format') | |
340 | - ps.Publisher().subscribe(self.ChangeBrushOperation, 'Set edition operation') | |
341 | - | |
344 | + ps.Publisher().subscribe(self.ChangeBrushSize, | |
345 | + 'Set edition brush size') | |
346 | + ps.Publisher().subscribe(self.ChangeBrushColour, | |
347 | + 'Add mask') | |
348 | + ps.Publisher().subscribe(self.ChangeBrushActor, | |
349 | + 'Set brush format') | |
350 | + ps.Publisher().subscribe(self.ChangeBrushOperation, | |
351 | + 'Set edition operation') | |
342 | 352 | |
343 | 353 | def ChangeBrushOperation(self, pubsub_evt): |
344 | 354 | print pubsub_evt.data |
... | ... | @@ -408,7 +418,7 @@ class Viewer(wx.Panel): |
408 | 418 | (self.layout[0] * self.layout[1]) |
409 | 419 | self.scroll.SetScrollbar(wx.SB_VERTICAL, 1, max_slice_number, |
410 | 420 | max_slice_number) |
411 | - self.SetScrollPosition(0) | |
421 | + self.set_scroll_position(0) | |
412 | 422 | |
413 | 423 | actor_bound = actor.GetBounds() |
414 | 424 | |
... | ... | @@ -423,7 +433,7 @@ class Viewer(wx.Panel): |
423 | 433 | |
424 | 434 | self.cursor = cursor |
425 | 435 | |
426 | - self.AppendMode('EDITOR') | |
436 | + self.append_mode('EDITOR') | |
427 | 437 | |
428 | 438 | def __update_cursor_position(self, position): |
429 | 439 | x, y, z = position |
... | ... | @@ -435,7 +445,7 @@ class Viewer(wx.Panel): |
435 | 445 | "AXIAL": [x, y, actor_bound[5] + 1 + slice_number]} |
436 | 446 | self.cursor.SetPosition(coordinates[self.orientation]) |
437 | 447 | |
438 | - def SetOrientation(self, orientation): | |
448 | + def set_orientation(self, orientation): | |
439 | 449 | self.orientation = orientation |
440 | 450 | for ren, actor, n in self.image_windows: |
441 | 451 | self.__update_camera(ren, actor, n) |
... | ... | @@ -478,13 +488,13 @@ class Viewer(wx.Panel): |
478 | 488 | def UpdateRender(self, evt): |
479 | 489 | self.interactor.Render() |
480 | 490 | |
481 | - def SetScrollPosition(self, position): | |
491 | + def set_scroll_position(self, position): | |
482 | 492 | self.scroll.SetThumbPosition(position) |
483 | 493 | self.OnScrollBar() |
484 | 494 | |
485 | 495 | def OnScrollBar(self, evt=None): |
486 | 496 | pos = self.scroll.GetThumbPosition() |
487 | - self.SetSliceNumber(pos) | |
497 | + self.set_slice_number(pos) | |
488 | 498 | self.interactor.Render() |
489 | 499 | if evt: |
490 | 500 | evt.Skip() |
... | ... | @@ -507,7 +517,7 @@ class Viewer(wx.Panel): |
507 | 517 | if evt: |
508 | 518 | evt.Skip() |
509 | 519 | |
510 | - def SetSliceNumber(self, index): | |
520 | + def set_slice_number(self, index): | |
511 | 521 | self.text_actor.SetInput(str(index)) |
512 | 522 | self.slice_number = index |
513 | 523 | for n, window in enumerate(self.image_windows): |
... | ... | @@ -528,11 +538,11 @@ class Viewer(wx.Panel): |
528 | 538 | |
529 | 539 | def ChangeSliceNumber(self, pubsub_evt): |
530 | 540 | index = pubsub_evt.data |
531 | - self.SetSliceNumber(index) | |
541 | + self.set_slice_number(index) | |
532 | 542 | self.scroll.SetThumbPosition(index) |
533 | 543 | self.interactor.Render() |
534 | 544 | |
535 | - def TestOperationPosition(self, coord): | |
545 | + def test_operation_position(self, coord): | |
536 | 546 | """ |
537 | 547 | Test if coord is into the imagedata limits. |
538 | 548 | """ | ... | ... |