Skip to content

Commit 18643ff

Browse files
committed
Merge pull request #1800 from UV-CDAT/fix_projected_click
Disable projected click, fix time values
2 parents bf097b7 + 78c96b8 commit 18643ff

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

Packages/vcs/Lib/VTKPlots.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,27 +124,16 @@ def leftButtonPressEvent(self, obj, event):
124124
continue
125125
t = vcs.elements["template"][d.template]
126126
gm = vcs.elements[d.g_type][d.g_name]
127+
if gm.projection != "linear":
128+
return
127129
if t.data.x1 <= x <= t.data.x2 and t.data.y1 <= y <= t.data.y2:
128-
# Ok we clicked within template
129-
if numpy.allclose(gm.datawc_x1, 1.e20):
130-
x1 = d.array[0].getAxis(-1)[0]
131-
else:
132-
x1 = gm.datawc_x1
133-
if numpy.allclose(gm.datawc_x2, 1.e20):
134-
x2 = d.array[0].getAxis(-1)[-1]
135-
else:
136-
x2 = gm.datawc_x2
137-
if numpy.allclose(gm.datawc_y1, 1.e20):
138-
y1 = d.array[0].getAxis(-2)[0]
139-
else:
140-
y1 = gm.datawc_y1
141-
if numpy.allclose(gm.datawc_y2, 1.e20):
142-
y2 = d.array[0].getAxis(-2)[-1]
143-
else:
144-
y2 = gm.datawc_y2
130+
x1, x2, y1, y2 = vcs.utils.getworldcoordinates(gm,
131+
d.array[0].getAxis(-1),
132+
d.array[0].getAxis(-2))
145133

146134
X = (x - t.data.x1) / (t.data.x2 - t.data.x1) * (x2 - x1) + x1
147135
Y = (y - t.data.y1) / (t.data.y2 - t.data.y1) * (y2 - y1) + y1
136+
148137
# Ok we now have the X/Y values we need to figure out the
149138
# indices
150139
try:
@@ -157,7 +146,16 @@ def leftButtonPressEvent(self, obj, event):
157146
except:
158147
V = d.array[0][..., I]
159148
if isinstance(V, numpy.ndarray):
160-
V = V.flat[0]
149+
# Grab the appropriate time slice
150+
if self.canvas.animate.created():
151+
t = self.canvas.animate.frame_num
152+
try:
153+
taxis = V.getTime()
154+
V = V(time=taxis[t % len(taxis)]).flat[0]
155+
except:
156+
V = V.flat[0]
157+
else:
158+
V = V.flat[0]
161159
try:
162160
st += "Var: %s\nX[%i] = %g\nY[%i] = %g\nValue: %g" % (
163161
d.array[0].id, I, X, J, Y, V)

0 commit comments

Comments
 (0)