wolfhece 2.1.118__py3-none-any.whl → 2.1.120__py3-none-any.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.
@@ -0,0 +1,2 @@
1
+ [Paths]
2
+ Plugins=../libs/qt_plugins
@@ -12,8 +12,12 @@ _viewer_dir = os.path.dirname(inspect.getfile(inspect.currentframe()))
12
12
  if not os.path.isabs(_viewer_dir):
13
13
  _viewer_dir = os.path.abspath(_viewer_dir)
14
14
 
15
- __all__ = ['viewer']
15
+ _viewer_libs_dir = os.path.join(_viewer_dir, '../libs')
16
+
17
+ if not os.path.isabs(_viewer_libs_dir):
18
+ _viewer_libs_dir = os.path.abspath(_viewer_libs_dir)
16
19
 
20
+ __all__ = ['viewer']
17
21
 
18
22
  class viewer:
19
23
  def __init__(self, *args, **kwargs):
@@ -22,7 +26,7 @@ class viewer:
22
26
  Examples:
23
27
  Create 100 random points
24
28
 
25
- >>> xyz = pptk.rand(100, 3)
29
+ >>> xyz = pptk.rand(100, 3)python
26
30
 
27
31
  Visualize the points
28
32
 
@@ -49,10 +53,16 @@ class viewer:
49
53
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
50
54
  s.bind(('localhost', 0))
51
55
  s.listen(0)
52
- self._process = subprocess.Popen(
53
- [os.path.join(_viewer_dir, 'viewer'), str(s.getsockname()[1])],
54
- stdout=subprocess.PIPE,
55
- stderr=(None if debug else subprocess.PIPE))
56
+
57
+ env = os.environ.copy()
58
+ env["PATH"] = _viewer_dir + os.pathsep + _viewer_libs_dir + os.pathsep + env["PATH"]
59
+ # print(env["PATH"])
60
+
61
+ self._process = subprocess.Popen([os.path.join(_viewer_dir, 'viewer'),
62
+ str(s.getsockname()[1])],
63
+ stdout=subprocess.PIPE,
64
+ stderr=(None if debug else subprocess.PIPE),
65
+ env = env)
56
66
  if debug:
57
67
  print ('Started viewer process: %s' \
58
68
  % os.path.join(_viewer_dir, 'viewer'))
@@ -366,6 +376,8 @@ class viewer:
366
376
  >>> ffmpeg -i "frame_%03d.png" -c:v mpeg4 -qscale:v 0 -r 24 output.mp4
367
377
 
368
378
  """
379
+ import time
380
+
369
381
  if not os.path.isdir(folder):
370
382
  raise ValueError('invalid folder provided')
371
383
  poses, ts = _fix_poses_ts_input(poses, ts)
@@ -394,12 +406,20 @@ class viewer:
394
406
  struct.pack('2f', t, t) + \
395
407
  struct.pack('?', False)
396
408
  self.__send(msg)
409
+
410
+ time.sleep(0.1)
411
+
397
412
  filename = prefix \
398
413
  + ('%0' + str(num_digits) + 'd') % (i + 1) + '.' + ext
399
414
  filename = os.path.join(folder, filename)
400
415
  self.capture(filename)
401
- # todo: need to check whether write succeeded
402
- # ideally, capture(...) should return filename
416
+ # check whether write succeeded
417
+
418
+ tot_sec = 0.
419
+ while not os.path.isfile(filename) and tot_sec < 5.:
420
+ # wait for file to be written
421
+ time.sleep(0.1)
422
+ tot_sec += 0.1
403
423
 
404
424
  def wait(self):
405
425
  """
@@ -1242,7 +1242,18 @@ class Matplotlib_Figure(wx.Frame):
1242
1242
  size_x, size_y = self.fig.get_size_inches()
1243
1243
 
1244
1244
  if self.wx_exists:
1245
- wx.Frame.__init__(self, None, -1, 'Matplotlib Figure', size=(size_x*dpi+16, size_y*dpi+240), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
1245
+ size_x = size_x*dpi+16
1246
+ size_y = size_y*dpi+240
1247
+
1248
+ #compare to screen size
1249
+ screen = wx.Display(0)
1250
+ screen_size = screen.GetGeometry().GetSize()
1251
+ if size_x > screen_size[0]:
1252
+ size_x = screen_size[0]
1253
+ if size_y > screen_size[1]:
1254
+ size_y = screen_size[1]
1255
+
1256
+ wx.Frame.__init__(self, None, -1, 'Matplotlib Figure', size=(size_x, size_y), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
1246
1257
 
1247
1258
  self.ax_dict:dict[str,Axes] = {} # dict of axes
1248
1259
  self.ax:list[Axes] = [] # list of axes -- always flatten
@@ -2048,6 +2059,13 @@ class Matplotlib_Figure(wx.Frame):
2048
2059
  return key, list(self.ax_dict.values()).index(key)
2049
2060
 
2050
2061
  def plot(self, x:np.ndarray, y:np.ndarray, ax:Axes | int | str= None, **kwargs):
2062
+ """ Plot x, y on the current ax or on the ax specified
2063
+
2064
+ :param x: x values
2065
+ :param y: y values
2066
+ :param ax: ax to plot on
2067
+ :param kwargs: kwargs for the plot (same as matplotlib.pyplot.plot)
2068
+ """
2051
2069
 
2052
2070
  ax, idx_ax = self.get_ax_idx(ax)
2053
2071
 
@@ -2068,8 +2086,72 @@ class Matplotlib_Figure(wx.Frame):
2068
2086
  self._line_current.SetSelection(len(ax.get_lines())-1)
2069
2087
 
2070
2088
  self.fig.tight_layout()
2089
+ self.fig.canvas.draw()
2071
2090
  self.update_layout()
2072
2091
 
2092
+ def scatter(self, x:np.ndarray, y:np.ndarray, ax:Axes | int | str= None, **kwargs):
2093
+ """ Scatter Plot x, y on the current ax or on the ax specified
2094
+
2095
+ :param x: x values
2096
+ :param y: y values
2097
+ :param ax: ax to plot on
2098
+ :param kwargs: kwargs for the plot (same as matplotlib.pyplot.plot)
2099
+ """
2100
+
2101
+ ax, idx_ax = self.get_ax_idx(ax)
2102
+
2103
+ ax.scatter(x, y, **kwargs)
2104
+
2105
+ new_props = Matplolib_line_properties(ax.get_lines()[-1], self._axes_properties[idx_ax])
2106
+
2107
+ if self.wx_exists:
2108
+ new_props.add_props_to_sizer(self._collaps_pane.GetPane(), self._sizer_grid_props)
2109
+
2110
+ ax_prop:Matplotlib_ax_properties = self._axes_properties[idx_ax]
2111
+ ax_prop._lines.append(new_props)
2112
+ ax_prop.get_properties()
2113
+
2114
+ if self.wx_exists:
2115
+ if ax == self.cur_ax:
2116
+ self._line_current.SetItems([line.get_label() for line in ax.get_lines()])
2117
+ self._line_current.SetSelection(len(ax.get_lines())-1)
2118
+
2119
+ self.fig.tight_layout()
2120
+ self.fig.canvas.draw()
2121
+ self.update_layout()
2122
+
2123
+ def violinplot(self, dataset:np.ndarray, position:np.ndarray=None, ax:Axes | int | str= None, **kwargs):
2124
+ """ Plot x, y on the current ax or on the ax specified
2125
+
2126
+ :param x: x values
2127
+ :param y: y values
2128
+ :param ax: ax to plot on
2129
+ :param kwargs: kwargs for the plot (same as matplotlib.pyplot.plot)
2130
+ """
2131
+
2132
+ ax, idx_ax = self.get_ax_idx(ax)
2133
+
2134
+ ax.violinplot(dataset, position, **kwargs)
2135
+
2136
+ # new_props = Matplolib_line_properties(ax.get_lines()[-1], self._axes_properties[idx_ax])
2137
+
2138
+ # if self.wx_exists:
2139
+ # new_props.add_props_to_sizer(self._collaps_pane.GetPane(), self._sizer_grid_props)
2140
+
2141
+ # ax_prop:Matplotlib_ax_properties = self._axes_properties[idx_ax]
2142
+ # ax_prop._lines.append(new_props)
2143
+ # ax_prop.get_properties()
2144
+
2145
+ # if self.wx_exists:
2146
+ # if ax == self.cur_ax:
2147
+ # self._line_current.SetItems([line.get_label() for line in ax.get_lines()])
2148
+ # self._line_current.SetSelection(len(ax.get_lines())-1)
2149
+
2150
+ self.fig.tight_layout()
2151
+ self.fig.canvas.draw()
2152
+ self.update_layout()
2153
+
2154
+
2073
2155
  def to_dict(self) -> dict:
2074
2156
  """ properties to dict """
2075
2157
 
wolfhece/opengl/py3d.py CHANGED
@@ -1238,7 +1238,7 @@ class CanvasOGL(glcanvas.GLCanvas):
1238
1238
  curarray = self.arrays[list(self.arrays.keys())[int(idx)-1]]
1239
1239
  i = int(x)
1240
1240
  j = int(y)
1241
-
1241
+
1242
1242
  if i > 0 and i < curarray.ztexture.shape[0] and j > 0 and j < curarray.ztexture.shape[1]:
1243
1243
  z = curarray.ztexture[i, j]
1244
1244
 
@@ -1798,9 +1798,15 @@ class Wolf_Viewer3D(wx.Frame):
1798
1798
  """ Add an array to the canvas """
1799
1799
  self.canvas.add_array(name, array)
1800
1800
 
1801
- def force_view(self, x, y, z):
1802
- """ Force the view to the specified coordinates """
1803
- self.canvas.force_view(x, y, z)
1801
+ def force_view(self, x, y, z= -1):
1802
+ """ Force the view to the specified coordinates.
1803
+
1804
+ if z == -1, the z value is the same as the current z value."""
1805
+ if z==-1:
1806
+ curx,cury,curz = self.canvas.center
1807
+ self.canvas.force_view(x, y, curz)
1808
+ else:
1809
+ self.canvas.force_view(x, y, z)
1804
1810
 
1805
1811
  def autoscale(self):
1806
1812
  """ Auto scale the view to fit all the arrays """