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]
|
||||
"""
|
||||
v2p_matrix = np.eye(4)
|
||||
v2p_matrix = np.eye(4) * -1
|
||||
v2p_matrix[0, 0] = 2. / (right - left)
|
||||
v2p_matrix[1, 1] = 2. / (right - left)
|
||||
v2p_matrix[2, 2] = 1. / (near - far)
|
||||
|
@ -612,19 +612,23 @@ class ClusterViewer(wx.Window):
|
|||
d = 20
|
||||
offset = 12
|
||||
|
||||
origin = np.array([0, 0, 0, 1]) # @UnusedVariable
|
||||
x_axis = np.array([d, 0, 0, 1])
|
||||
y_axis = np.array([0, d, 0, 1])
|
||||
z_axis = np.array([0, 0, d, 1])
|
||||
points = np.array([[d, 0, 0, 1, 0],
|
||||
[0, d, 0, 1, 1],
|
||||
[0, 0, d, 1, 2]])
|
||||
|
||||
# translation = np.array([[1, 0, 0, d + offset], # @UnusedVariable
|
||||
# [0, 1, 0, h - offset],
|
||||
# [0, 0, 1, 1 ],
|
||||
# [0, 0, 0, 1 ]])
|
||||
# project onto viewport
|
||||
projections = np.dot(points[:, :4], m_matrix)
|
||||
projections /= projections[:, -1, None]
|
||||
# add the other columns
|
||||
projections = np.c_[projections, points[:, 4:]]
|
||||
# and sort by Z
|
||||
projections = projections[projections[:,2].argsort()[::-1]]
|
||||
|
||||
red = (1, 0, 0)
|
||||
green = (0, 0.7, 0)
|
||||
blue = (0, 0, 1)
|
||||
colors = (red, green, blue)
|
||||
labels = ('X', 'Y', 'Z')
|
||||
|
||||
# draw a white circle
|
||||
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.fill()
|
||||
|
||||
for axis, color, label in ((x_axis, red, 'X'),
|
||||
(y_axis, green, 'Y'),
|
||||
(z_axis, blue, 'Z')):
|
||||
axis = np.dot(axis, m_matrix)
|
||||
axis /= axis[-1]
|
||||
for x, y, z, w, n in projections:
|
||||
n = int(n)
|
||||
ctx.move_to(*so[:2])
|
||||
ctx.rel_line_to(*axis[:2])
|
||||
ctx.set_source_rgb(*color)
|
||||
ctx.rel_line_to(x, y)
|
||||
ctx.set_source_rgb(*colors[n])
|
||||
ctx.set_line_width(2)
|
||||
ctx.set_font_size(10)
|
||||
ctx.show_text(label)
|
||||
ctx.show_text(labels[n])
|
||||
ctx.stroke()
|
||||
|
||||
|
||||
def render_atoms(self, ctx):
|
||||
try:
|
||||
atoms = self.atoms
|
||||
|
|
Loading…
Reference in New Issue