Skip to content

Commit a13109e

Browse files
committed
glcannon -show a grid in perspective mode too
stolen from QtPlasmac code.
1 parent 3c7cc2e commit a13109e

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

lib/python/rs274/glcanon.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,20 +1188,29 @@ def draw_grid_permuted(self, rotation, permutation, inverse_permutation):
11881188
def draw_grid(self):
11891189

11901190
view = self.get_view()
1191-
if view == VP: return
11921191
rotation = math.radians(self.stat.rotation_xy % 90)
1193-
if rotation != 0 and view != VZ and self.get_show_relative(): return
1194-
permutations = [
1192+
1193+
# perspective view (code stolen from the QtPlasmac crew)
1194+
if view == VP:
1195+
def permutation(x_y_z2):
1196+
return x_y_z2[0], x_y_z2[1], x_y_z2[2] # XY Z
1197+
def inverse_permutation(x_y_z3):
1198+
return x_y_z3[0], x_y_z3[1], x_y_z3[2] # XY Z
1199+
self.draw_grid_permuted(rotation, permutation, inverse_permutation)
1200+
1201+
# all other views
1202+
else:
1203+
permutations = [
11951204
lambda x_y_z: (x_y_z[2], x_y_z[1], x_y_z[0]), # YZ X
11961205
lambda x_y_z1: (x_y_z1[2], x_y_z1[0], x_y_z1[1]), # ZX Y
11971206
lambda x_y_z2: (x_y_z2[0], x_y_z2[1], x_y_z2[2]), # XY Z
1198-
]
1199-
inverse_permutations = [
1207+
]
1208+
inverse_permutations = [
12001209
lambda z_y_x: (z_y_x[2], z_y_x[1], z_y_x[0]), # YZ X
12011210
lambda z_x_y: (z_x_y[1], z_x_y[2], z_x_y[0]), # ZX Y
12021211
lambda x_y_z3: (x_y_z3[0], x_y_z3[1], x_y_z3[2]), # XY Z
1203-
]
1204-
self.draw_grid_permuted(rotation, permutations[view],
1212+
]
1213+
self.draw_grid_permuted(rotation, permutations[view],
12051214
inverse_permutations[view])
12061215

12071216
def all_joints_homed(self):

0 commit comments

Comments
 (0)