Fix axes graphical bug in clusterviewer.
X, Y, Z axes were not in the right-hand orientation and the Z-stack for drawing axes was not updated resulting in strange graphical output (axis could "jump" over another instead of being drawn behind)
This commit is contained in:
parent
54fc166eb4
commit
3a20719d19
|
@ -530,7 +530,7 @@ class ClusterViewer(wx.Window):
|
||||||
|
|
||||||
this transformation is a scale and offset that maps [left; right], [bottom; top], [near; far] to [-1;1], [-1;1], [0;1]
|
this transformation is a scale and offset that maps [left; right], [bottom; top], [near; far] to [-1;1], [-1;1], [0;1]
|
||||||
"""
|
"""
|
||||||
v2p_matrix = np.eye(4)
|
v2p_matrix = np.eye(4) * -1
|
||||||
v2p_matrix[0, 0] = 2. / (right - left)
|
v2p_matrix[0, 0] = 2. / (right - left)
|
||||||
v2p_matrix[1, 1] = 2. / (right - left)
|
v2p_matrix[1, 1] = 2. / (right - left)
|
||||||
v2p_matrix[2, 2] = 1. / (near - far)
|
v2p_matrix[2, 2] = 1. / (near - far)
|
||||||
|
@ -612,19 +612,23 @@ class ClusterViewer(wx.Window):
|
||||||
d = 20
|
d = 20
|
||||||
offset = 12
|
offset = 12
|
||||||
|
|
||||||
origin = np.array([0, 0, 0, 1]) # @UnusedVariable
|
points = np.array([[d, 0, 0, 1, 0],
|
||||||
x_axis = np.array([d, 0, 0, 1])
|
[0, d, 0, 1, 1],
|
||||||
y_axis = np.array([0, d, 0, 1])
|
[0, 0, d, 1, 2]])
|
||||||
z_axis = np.array([0, 0, d, 1])
|
|
||||||
|
|
||||||
# translation = np.array([[1, 0, 0, d + offset], # @UnusedVariable
|
# project onto viewport
|
||||||
# [0, 1, 0, h - offset],
|
projections = np.dot(points[:, :4], m_matrix)
|
||||||
# [0, 0, 1, 1 ],
|
projections /= projections[:, -1, None]
|
||||||
# [0, 0, 0, 1 ]])
|
# add the other columns
|
||||||
|
projections = np.c_[projections, points[:, 4:]]
|
||||||
|
# and sort by Z
|
||||||
|
projections = projections[projections[:,2].argsort()[::-1]]
|
||||||
|
|
||||||
red = (1, 0, 0)
|
red = (1, 0, 0)
|
||||||
green = (0, 0.7, 0)
|
green = (0, 0.7, 0)
|
||||||
blue = (0, 0, 1)
|
blue = (0, 0, 1)
|
||||||
|
colors = (red, green, blue)
|
||||||
|
labels = ('X', 'Y', 'Z')
|
||||||
|
|
||||||
# draw a white circle
|
# draw a white circle
|
||||||
so = np.array([d + offset, h - d - offset, 0])
|
so = np.array([d + offset, h - d - offset, 0])
|
||||||
|
@ -637,19 +641,17 @@ class ClusterViewer(wx.Window):
|
||||||
ctx.set_source_rgba(0.95, 0.95, 0.95, 1)
|
ctx.set_source_rgba(0.95, 0.95, 0.95, 1)
|
||||||
ctx.fill()
|
ctx.fill()
|
||||||
|
|
||||||
for axis, color, label in ((x_axis, red, 'X'),
|
for x, y, z, w, n in projections:
|
||||||
(y_axis, green, 'Y'),
|
n = int(n)
|
||||||
(z_axis, blue, 'Z')):
|
|
||||||
axis = np.dot(axis, m_matrix)
|
|
||||||
axis /= axis[-1]
|
|
||||||
ctx.move_to(*so[:2])
|
ctx.move_to(*so[:2])
|
||||||
ctx.rel_line_to(*axis[:2])
|
ctx.rel_line_to(x, y)
|
||||||
ctx.set_source_rgb(*color)
|
ctx.set_source_rgb(*colors[n])
|
||||||
ctx.set_line_width(2)
|
ctx.set_line_width(2)
|
||||||
ctx.set_font_size(10)
|
ctx.set_font_size(10)
|
||||||
ctx.show_text(label)
|
ctx.show_text(labels[n])
|
||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
|
|
||||||
|
|
||||||
def render_atoms(self, ctx):
|
def render_atoms(self, ctx):
|
||||||
try:
|
try:
|
||||||
atoms = self.atoms
|
atoms = self.atoms
|
||||||
|
|
Loading…
Reference in New Issue