(self, style)
| 26 | # Main testing proc |
| 27 | |
| 28 | def test_style(self, style): |
| 29 | |
| 30 | # Event state to test |
| 31 | |
| 32 | buttons = ["Left", "Middle", "Right"] |
| 33 | ctrls = [0, 1] |
| 34 | shifts = [0, 1] |
| 35 | |
| 36 | # I do not trust timers while testing (since they trigger asynchronous |
| 37 | # rendering/interaction) |
| 38 | |
| 39 | use_timers = style.GetUseTimers() |
| 40 | style.UseTimersOff() |
| 41 | style.AutoAdjustCameraClippingRangeOn() |
| 42 | |
| 43 | print("Testing: " + style.GetClassName()) |
| 44 | |
| 45 | iren = style.GetInteractor() |
| 46 | renwin = iren.GetRenderWindow() |
| 47 | |
| 48 | renwin.Render() |
| 49 | |
| 50 | # Get renwin size and center |
| 51 | |
| 52 | win_size = renwin.GetSize() |
| 53 | win_center_x = win_size[0] / (2.0) |
| 54 | win_center_y = win_size[1] / (2.0) |
| 55 | |
| 56 | # The following line can be problematic, it may use a different picker |
| 57 | # than what the interactions style uses causing inconsistencies. |
| 58 | pick = vtkPropPicker() |
| 59 | |
| 60 | radius = 5 * (1 + use_timers) |
| 61 | |
| 62 | for ctrl in ctrls: |
| 63 | for shift in shifts: |
| 64 | print(" - ctrl: " + str(ctrl) + " shift: " + str(shift) + " " + "button: ", end=' ') |
| 65 | for button in buttons: |
| 66 | print(button, end=' ') |
| 67 | # First try to find a starting position where an actor |
| 68 | # can be picked (not mandatory for trackball modes). |
| 69 | # Search in increasingly big area, until we reach win size |
| 70 | # in that case actors might not be on screen, so reset cam |
| 71 | |
| 72 | search = radius |
| 73 | while True: |
| 74 | start_x = self.randint(win_center_x - search, win_center_x + search) |
| 75 | start_y = self.randint(win_center_x - search, win_center_x + search) |
| 76 | if pick.PickProp(start_x, start_y, self.ren1): |
| 77 | break |
| 78 | else: |
| 79 | if search > win_center_x or search > win_center_y: |
| 80 | print(" (resetting camera)", end=' ') |
| 81 | self.ren1.ResetCamera() |
| 82 | search = radius |
| 83 | else: |
| 84 | search += 5 |
| 85 |
no test coverage detected