vispy 0.14.3__cp312-cp312-win_amd64.whl → 0.15.2__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of vispy might be problematic. Click here for more details.

vispy/gloo/program.py CHANGED
@@ -362,7 +362,7 @@ class Program(GLObject):
362
362
  data = TextureCube(data)
363
363
  else:
364
364
  # This should not happen
365
- raise RuntimeError('Unknown type %s' % type_)
365
+ raise RuntimeError('Unknown type %s for %s' % (type_, name))
366
366
  # Store and send GLIR command
367
367
  self._user_variables[name] = data
368
368
  self.glir.associate(data.glir)
@@ -442,7 +442,7 @@ class Program(GLObject):
442
442
  self._glir.command('ATTRIBUTE', self._id,
443
443
  name, type_, value, divisor)
444
444
  else:
445
- raise KeyError('Cannot set data for a %s.' % kind)
445
+ raise KeyError('Cannot set data for a %s (%s).' % (kind, name))
446
446
  else:
447
447
  # This variable is not defined in the current source code,
448
448
  # so we cannot establish whether this is a uniform or
@@ -6,7 +6,6 @@ from __future__ import division
6
6
 
7
7
  import numpy as np
8
8
 
9
-
10
9
  from ...util import transforms
11
10
  from ...util.quaternion import Quaternion
12
11
  from ...visuals.transforms import MatrixTransform
@@ -57,7 +56,7 @@ class ArcballCamera(Base3DRotationCamera):
57
56
 
58
57
  def _update_rotation(self, event):
59
58
  """Update rotation parmeters based on mouse movement"""
60
- p2 = event.mouse_event.pos
59
+ p2 = event.pos[:2]
61
60
  if self._event_value is None:
62
61
  self._event_value = p2
63
62
  wh = self._viewbox.size
@@ -3,6 +3,7 @@
3
3
  # Distributed under the (new) BSD License. See LICENSE.txt for more info.
4
4
 
5
5
  from __future__ import division
6
+ from contextlib import contextmanager
6
7
 
7
8
  from ...util import keys
8
9
  from ..node import Node
@@ -211,11 +212,14 @@ class BaseCamera(Node):
211
212
  @center.setter
212
213
  def center(self, val):
213
214
  if len(val) == 2:
214
- self._center = float(val[0]), float(val[1]), 0.0
215
+ center = float(val[0]), float(val[1]), 0.0
215
216
  elif len(val) == 3:
216
- self._center = float(val[0]), float(val[1]), float(val[2])
217
+ center = float(val[0]), float(val[1]), float(val[2])
217
218
  else:
218
219
  raise ValueError('Center must be a 2 or 3 element tuple')
220
+ if center == self._center:
221
+ return
222
+ self._center = center
219
223
  self.view_changed()
220
224
 
221
225
  @property
@@ -233,6 +237,12 @@ class BaseCamera(Node):
233
237
  self._fov = fov
234
238
  self.view_changed()
235
239
 
240
+ @contextmanager
241
+ def _block_updates(self):
242
+ prev, self._resetting = self._resetting, True
243
+ yield
244
+ self._resetting = prev
245
+
236
246
  # Camera methods
237
247
 
238
248
  def set_range(self, x=None, y=None, z=None, margin=0.05):
@@ -276,31 +286,30 @@ class BaseCamera(Node):
276
286
  return
277
287
 
278
288
  # There is a viewbox, we're going to set the range for real
279
- self._resetting = True
289
+ with self._block_updates():
280
290
 
281
- # Get bounds from viewbox if not given
282
- if all([(b is None) for b in bounds]):
283
- bounds = self._viewbox.get_scene_bounds()
284
- else:
285
- for i in range(3):
286
- if bounds[i] is None:
287
- bounds[i] = self._viewbox.get_scene_bounds(i)
288
-
289
- # Calculate ranges and margins
290
- ranges = [b[1] - b[0] for b in bounds]
291
- margins = [(r*margin or 0.1) for r in ranges]
292
- # Assign limits for this camera
293
- bounds_margins = [(b[0]-m, b[1]+m) for b, m in zip(bounds, margins)]
294
- self._xlim, self._ylim, self._zlim = bounds_margins
295
- # Store center location
296
- if (not init) or (self._center is None):
297
- self._center = [(b[0] + r / 2) for b, r in zip(bounds, ranges)]
298
-
299
- # Let specific camera handle it
300
- self._set_range(init)
291
+ # Get bounds from viewbox if not given
292
+ if all([(b is None) for b in bounds]):
293
+ bounds = self._viewbox.get_scene_bounds()
294
+ else:
295
+ for i in range(3):
296
+ if bounds[i] is None:
297
+ bounds[i] = self._viewbox.get_scene_bounds(i)
298
+
299
+ # Calculate ranges and margins
300
+ ranges = [b[1] - b[0] for b in bounds]
301
+ margins = [(r*margin or 0.1) for r in ranges]
302
+ # Assign limits for this camera
303
+ bounds_margins = [(b[0]-m, b[1]+m) for b, m in zip(bounds, margins)]
304
+ self._xlim, self._ylim, self._zlim = bounds_margins
305
+ # Store center location
306
+ if (not init) or (self._center is None):
307
+ self._center = [(b[0] + r / 2) for b, r in zip(bounds, ranges)]
308
+
309
+ # Let specific camera handle it
310
+ self._set_range(init)
301
311
 
302
312
  # Finish
303
- self._resetting = False
304
313
  self.view_changed()
305
314
 
306
315
  def _set_range(self, init):
@@ -357,32 +366,34 @@ class BaseCamera(Node):
357
366
  state = state or {}
358
367
  state.update(kwargs)
359
368
 
360
- # In first pass, process tuple keys which select subproperties. This
361
- # is an undocumented feature used for selective linking of camera state.
362
- #
363
- # Subproperties are handled by first copying old value of the root
364
- # property, then setting the subproperty on this copy, and finally
365
- # assigning the copied object back to the camera property. There needs
366
- # to be an assignment of the root property so setters are called and
367
- # update is triggered.
368
- for key in list(state.keys()):
369
- if isinstance(key, tuple):
370
- key1 = key[0]
371
- if key1 not in state:
372
- root_prop = getattr(self, key1)
373
- # We make copies by passing the old object to the type's
374
- # constructor. This needs to be supported as is the case in
375
- # e.g. the geometry.Rect class.
376
- state[key1] = root_prop.__class__(root_prop)
377
- nested_setattr(state[key1], key[1:], state[key])
378
-
379
- # In second pass, assign the new root properties.
380
- for key, val in state.items():
381
- if isinstance(key, tuple):
382
- continue
383
- if key not in self._state_props:
384
- raise KeyError('Not a valid camera state property %r' % key)
385
- setattr(self, key, val)
369
+ with self._block_updates():
370
+ # In first pass, process tuple keys which select subproperties. This
371
+ # is an undocumented feature used for selective linking of camera state.
372
+ #
373
+ # Subproperties are handled by first copying old value of the root
374
+ # property, then setting the subproperty on this copy, and finally
375
+ # assigning the copied object back to the camera property. There needs
376
+ # to be an assignment of the root property so setters are called and
377
+ # update is triggered.
378
+ for key in list(state.keys()):
379
+ if isinstance(key, tuple):
380
+ key1 = key[0]
381
+ if key1 not in state:
382
+ root_prop = getattr(self, key1)
383
+ # We make copies by passing the old object to the type's
384
+ # constructor. This needs to be supported as is the case in
385
+ # e.g. the geometry.Rect class.
386
+ state[key1] = root_prop.__class__(root_prop)
387
+ nested_setattr(state[key1], key[1:], state[key])
388
+
389
+ # In second pass, assign the new root properties.
390
+ for key, val in state.items():
391
+ if isinstance(key, tuple):
392
+ continue
393
+ if key not in self._state_props:
394
+ raise KeyError('Not a valid camera state property %r' % key)
395
+ setattr(self, key, val)
396
+ self.view_changed()
386
397
 
387
398
  def link(self, camera, props=None, axis=None):
388
399
  """Link this camera with another camera of the same type
@@ -508,6 +519,8 @@ class BaseCamera(Node):
508
519
 
509
520
  def _set_scene_transform(self, tr):
510
521
  """Called by subclasses to configure the viewbox scene transform."""
522
+ if self._resetting:
523
+ return
511
524
  # todo: check whether transform has changed, connect to
512
525
  # transform.changed event
513
526
  pre_tr = self.pre_transform
@@ -164,7 +164,7 @@ class PanZoomCamera(BaseCamera):
164
164
  def center(self, center):
165
165
  if not (isinstance(center, (tuple, list)) and len(center) in (2, 3)):
166
166
  raise ValueError('center must be a 2 or 3 element tuple')
167
- rect = Rect(self.rect) or Rect(*DEFAULT_RECT_TUPLE)
167
+ rect = Rect(self.rect) or Rect(*DEFAULT_RECT_TUPLE) # make a copy of self.rect
168
168
  rect.center = center[:2]
169
169
  self.rect = rect
170
170
 
@@ -246,6 +246,9 @@ class PanZoomCamera(BaseCamera):
246
246
  event.handled = False
247
247
 
248
248
  def _update_transform(self):
249
+ if self._resetting: # base camera linking operation
250
+ return
251
+
249
252
  rect = self.rect
250
253
  self._real_rect = Rect(rect)
251
254
  vbr = self._viewbox.rect.flipped(x=self.flip[0], y=(not self.flip[1]))
@@ -80,7 +80,10 @@ class PerspectiveCamera(BaseCamera):
80
80
 
81
81
  @scale_factor.setter
82
82
  def scale_factor(self, value):
83
- self._scale_factor = abs(float(value))
83
+ value = abs(float(value))
84
+ if value == self._scale_factor:
85
+ return
86
+ self._scale_factor = value
84
87
  self.view_changed()
85
88
 
86
89
  @property
@@ -137,6 +140,8 @@ class PerspectiveCamera(BaseCamera):
137
140
  # Do we have a viewbox
138
141
  if self._viewbox is None:
139
142
  return
143
+ if self._resetting: # base camera linking operation
144
+ return
140
145
 
141
146
  # Calculate viewing range for x and y
142
147
  fx = fy = self._scale_factor
@@ -73,6 +73,9 @@ class TurntableCamera(Base3DRotationCamera):
73
73
  super(TurntableCamera, self).__init__(fov=fov, **kwargs)
74
74
 
75
75
  # Set camera attributes
76
+ self._azimuth = azimuth
77
+ self._elevation = elevation
78
+ self._roll = roll
76
79
  self.azimuth = azimuth
77
80
  self.elevation = elevation
78
81
  self.roll = roll
@@ -90,7 +93,10 @@ class TurntableCamera(Base3DRotationCamera):
90
93
  @elevation.setter
91
94
  def elevation(self, elev):
92
95
  elev = float(elev)
93
- self._elevation = min(90, max(-90, elev))
96
+ elev = min(90, max(-90, elev))
97
+ if elev == self._elevation:
98
+ return
99
+ self._elevation = elev
94
100
  self.view_changed()
95
101
 
96
102
  @property
@@ -108,6 +114,8 @@ class TurntableCamera(Base3DRotationCamera):
108
114
  azim += 360
109
115
  while azim > 180:
110
116
  azim -= 360
117
+ if azim == self._azimuth:
118
+ return
111
119
  self._azimuth = azim
112
120
  self.view_changed()
113
121
 
@@ -123,6 +131,8 @@ class TurntableCamera(Base3DRotationCamera):
123
131
  roll += 360
124
132
  while roll > 180:
125
133
  roll -= 360
134
+ if roll == self._roll:
135
+ return
126
136
  self._roll = roll
127
137
  self.view_changed()
128
138