diff --git a/docs/changes.md b/docs/changes.md index de8ac4cd..83a089d5 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,6 +1,9 @@ ## Main changes -- rename module `io.py` to `file_io.py` to avoid override stlib io. +- Rename module `io.py` to `file_io.py` to avoid override stlib io. +- Complete revision of cutter widgets funcionatlity +- Integration in napari thanks to @jo-mueller + ### Breaking changes - method `plotter.add()` no more accepts keyword `render=True/False`. Please use `plotter.add().render()` explicitly. Same thing for `plotter.remove()`. @@ -26,7 +29,7 @@ - Update API Documentation for Changing Backend by @bhacha - Add `application.Browser().play()` to autoplay a slider - Add `pad()` to padding a Volume with zeros voxels (useful to `dilate()`) -- Add `ProgressBarWindow()` to show a progress bar in the rendering window +- Add `ProgressBarWidget()` to show a progress bar in the rendering window - Fix Scalarbar3D logscale and change separator symbol by @XushanLu - Fix `vedo/interactor_modes.mouse_left_move()` by @MiticoDan - Added `applications.AnimationPlayer` class by @mikaeltulldahl @@ -51,11 +54,23 @@ examples/simulations/aspring2_player.py ``` airplane1.py examples/simulations/trail.py +particle_simulator.py ``` +align4.py +bgImage.py +colormap_list.py +mousehover3.py +cut_with_points2.py +interpolate_field.py +goniometer.py +pendulum_3d.pyq +graph_lineage.py +graph_network.py +markpoint.py +plot_stream.py - - +meshio_read.py diff --git a/tests/dolfinx/run_all.sh b/tests/dolfinx/run_all.sh deleted file mode 100755 index de9535a9..00000000 --- a/tests/dolfinx/run_all.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# source run_all.sh -# -for f in test_*.py -do - echo "Processing $f script.." - python3 "$f" -done diff --git a/tests/common/test_docs_sniplets.py b/tests/snippets/test_docs_sniplets.py similarity index 94% rename from tests/common/test_docs_sniplets.py rename to tests/snippets/test_docs_sniplets.py index da175b20..0bc2cd4c 100644 --- a/tests/common/test_docs_sniplets.py +++ b/tests/snippets/test_docs_sniplets.py @@ -4,7 +4,7 @@ from vedo.pyplot import plot import vedo -doshow = 0 +doshow = 1 ##################################################################### addons.py box = Box(pos=(1,2,3), length=8, width=9, height=7).alpha(0.1) @@ -15,6 +15,7 @@ show(box, axs).close() ###################################################### +print("Test 1") b = Box(pos=(0, 0, 0), length=80, width=90, height=70).alpha(0.1) if doshow: show( @@ -27,6 +28,7 @@ ).close() ##################################################################### base.py +print("Test 2") c1 = Cube() c2 = c1.clone().c('violet').alpha(0.5) # copy of c1 v = vector(0.2,1,0) @@ -38,6 +40,7 @@ ###################################################### +print("Test 3") objs = [] for i in range(-5, 5): p = [i/3, i/2, i] @@ -49,6 +52,7 @@ ###################################################### +print("Test 4") c1 = Cube() c2 = c1.clone().c('violet').alpha(0.5) # copy of c1 v = vector(0.2,1,0) @@ -64,6 +68,7 @@ ###################################################### +print("Test 5") tetmesh = TetMesh(dataurl+'limb_ugrid.vtk') tetmesh.color('rainbow') cu = Cube(side=500).x(500) # any Mesh works @@ -72,11 +77,13 @@ show(axes=1).close() ##################################################################### mesh.py +print("Test 6") s = Sphere().crop(right=0.3, left=0.1) if doshow: show(s).close() ###################################################### +print("Test 7") c1 = Cylinder(pos=(0,0,0), r=2, height=3, axis=(1,.0,0), alpha=.1).triangulate() c2 = Cylinder(pos=(0,0,2), r=1, height=2, axis=(0,.3,1), alpha=.1).triangulate() intersect = c1.intersect_with(c2).join(reset=True) @@ -86,6 +93,7 @@ ###################################################### +print("Test 8") grid = Grid()#.triangulate() circle = Circle(r=0.3, res=24).pos(0.11,0.12) line = Line(circle, closed=True, lw=4, c='r4') @@ -95,6 +103,7 @@ ##################################################################### picture.py +print("Test 9") if doshow: pic = Picture(dataurl+'dog.jpg').pad() pic.append([pic,pic,pic], axis='y') @@ -103,6 +112,7 @@ ###################################################### +print("Test 10") if doshow: p = vedo.Picture(vedo.dataurl+'images/dog.jpg').bw() pe = p.clone().enhance() @@ -111,6 +121,7 @@ ###################################################### +print("Test 11") if doshow: pic1 = Picture("https://aws.glamour.es/prod/designs/v1/assets/620x459/547577.jpg") pic2 = pic1.clone().invert() @@ -120,6 +131,7 @@ ###################################################### +print("Test 12") if doshow: pic = vedo.Picture(vedo.dataurl+"images/dog.jpg") pic.rectangle([100,300], [100,200], c='green4', alpha=0.7) @@ -129,12 +141,14 @@ ##################################################################### plotter.py +print("Test 13") cone = Cone() if doshow: cone.show(axes=1).fly_to([1,0,0]) cone.show().close() ###################################################### +print("Test 14") settings.use_parallel_projection = True # or else it doesnt make sense! cube = Cube().alpha(0.2) plt = Plotter(size=(900,600), axes=dict(xtitle='x (um)')) @@ -144,12 +158,12 @@ settings.use_parallel_projection = False ###################################################### +print("Test 15") def func(evt): # called every time the mouse moves # evt is a dotted dictionary if not evt.actor: return # no hit, return print("point coords =", evt.picked3d) - # print("full event dump:", evt) elli = Ellipsoid() plt = Plotter(axes=1) @@ -159,6 +173,7 @@ def func(evt): # called every time the mouse moves ##################################################################### pointcloud.py +print("Test 16") s = Ellipsoid().rotate_y(30) #Camera options: pos, focal_point, viewup, distance, # clippingRange, parallelScale, thickness, viewAngle @@ -171,6 +186,7 @@ def func(evt): # called every time the mouse moves ###################################################### +print("Test 17") def fibonacci_sphere(n): s = np.linspace(0, n, num=n, endpoint=False) theta = s * 2.399963229728653 @@ -185,6 +201,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 18") s = Sphere(res=10).linewidth(1).c("orange").compute_normals() point_ids = s.labels('id', on="points").c('green') cell_ids = s.labels('id', on="cells").c('black') @@ -194,6 +211,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 19") sph = Sphere(quads=True, res=4).compute_normals().wireframe() sph.celldata["zvals"] = sph.cell_centers()[:,2] l2d = sph.labels("zvals", on="cells", precision=2).backcolor('orange9') @@ -203,6 +221,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 20") c1 = Cube().rotate_z(5).x(2).y(1) print("cube1 position", c1.pos()) T = c1.get_transform() # rotate by 5 degrees, sum 2 to x and 1 to y @@ -217,6 +236,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 21") disc = Disc(r1=1, r2=1.2) mesh = disc.extrude(3, res=50).linewidth(1) mesh.cut_with_cylinder([0,0,2], r=0.4, axis='y', invert=True) @@ -225,6 +245,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 22") disc = Disc(r1=1, r2=1.2) mesh = disc.extrude(3, res=50).linewidth(1) mesh.cut_with_sphere([1,-0.7,2], r=1.5, invert=True) @@ -233,6 +254,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 23") arr = np.random.randn(100000, 3)/2 pts = Points(arr).c('red3').pos(5,0,0) cube = Cube().pos(4,0.5,0) @@ -242,6 +264,7 @@ def fibonacci_sphere(n): ##################################################################### shapes.py +print("Test 24") pts = [[1, 0, 0], [5, 2, 0], [3, 3, 1]] ln = Line(pts, c='r', lw=5).pattern('- -', repeats=10) if doshow: @@ -250,6 +273,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 25") if doshow: shape = load(dataurl+"timecourse1d.npy")[58] pts = shape.rotate_x(30).points() @@ -259,6 +283,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 26") if doshow: shape = load(dataurl+"timecourse1d.npy")[55] curvs = Line(shape.points()).curvature() @@ -270,6 +295,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 27") aline = Line([(0,0,0),(1,3,0),(2,4,0)]) surf1 = aline.sweep((1,0.2,0), res=3) surf2 = aline.sweep((0.2,0,1)) @@ -279,6 +305,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 28") pts = [(-4,-3),(1,1),(2,4),(4,1),(3,-1),(2,-5),(9,-3)] ln = Line(pts, c='r', lw=2).z(0.01) rl = RoundedLine(pts, 0.6) @@ -287,6 +314,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 29") pts = np.random.randn(25,3) for i,p in enumerate(pts): p += [5*i, 15*sin(i/2), i*i*i/200] @@ -295,6 +323,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 30") xcoords = np.arange(0, 2, 0.2) ycoords = np.arange(0, 1, 0.2) sqrtx = sqrt(xcoords) @@ -310,6 +339,7 @@ def fibonacci_sphere(n): ###################################################### +print("Test 31") settings.immediate_rendering = False plt = Plotter(N=18) for i in range(18): diff --git a/vedo/applications.py b/vedo/applications.py index fb5658e2..0321dc18 100644 --- a/vedo/applications.py +++ b/vedo/applications.py @@ -990,7 +990,7 @@ def _on_keypress(self, evt): pts = self.spline.points() n = fit_plane(pts, signed=True).normal # compute normal vector to points rb = Ribbon(pts - tol * n, pts + tol * n, closed=True) - self.mesh.cutWithMesh(rb, invert=inv) # CUT + self.mesh.cut_with_mesh(rb, invert=inv) # CUT self.txt2d.text(self.msg) # put back original message if self.drawmode: self._on_right_click(evt) # toggle mode to normal diff --git a/vedo/interactor_modes.py b/vedo/interactor_modes.py index 70589bba..a9a255d2 100644 --- a/vedo/interactor_modes.py +++ b/vedo/interactor_modes.py @@ -125,10 +125,10 @@ def _right_up(self, w, e): self.right = False def _wheel_forward(self, w, e): - self.mouse_wheel_forward() + self._mouse_wheel_forward() def _wheel_backward(self, w, e): - self.mouse_wheel_backward() + self._mouse_wheel_backward() def _mouse_move(self, w, e): if self.left: diff --git a/vedo/mesh.py b/vedo/mesh.py index 61f9a724..48c88b90 100644 --- a/vedo/mesh.py +++ b/vedo/mesh.py @@ -1398,11 +1398,6 @@ def check_validity(self, tol=0): varr = vald.GetOutput().GetCellData().GetArray("ValidityState") return vtk2numpy(varr) - @deprecated(reason=vedo.colors.red + "Please use compute_curvature()" + vedo.colors.reset) - def addCurvatureScalars(self, method=0): - """Deprecated. Please use `compute_curvature()`""" - return self.compute_curvature(method) - def compute_curvature(self, method=0): """ Add scalars to `Mesh` that contains the curvature calculated in three different ways. diff --git a/vedo/pointcloud.py b/vedo/pointcloud.py index 14f7c128..65379b95 100644 --- a/vedo/pointcloud.py +++ b/vedo/pointcloud.py @@ -1517,11 +1517,6 @@ def compute_acoplanarity(self, n=25, radius=None, on="points"): self.celldata["Acoplanarity"] = np.array(acoplanarities, dtype=float) return self - @deprecated(reason=vedo.colors.red + "Please use distance_to()" + vedo.colors.reset) - def distanceTo(self, pcloud, signed=False, invert=False, name="Distance"): - "Please use `distance_to()`." - return self.distance_to(pcloud, signed, invert, name) - def distance_to(self, pcloud, signed=False, invert=False, name="Distance"): """ Computes the distance from one point cloud or mesh to another point cloud or mesh. @@ -1617,11 +1612,6 @@ def force_translucent(self, value=True): self.SetForceTranslucent(value) return self - @deprecated(reason=vedo.colors.red + "Please use point_size()" + vedo.colors.reset) - def pointSize(self, value): - "Deprecated. Please use `point_size()`." - return self.point_size(value) - def point_size(self, value=None): """Set/get mesh's point size of vertices. Same as `mesh.ps()`""" if value is None: @@ -1795,12 +1785,6 @@ def average_size(self): cc = coords - cm return np.mean(np.linalg.norm(cc, axis=1)) - - @deprecated(reason=vedo.colors.red + "Please use center_of_mass()" + vedo.colors.reset) - def centerOfMass(self): - "Deprecated. Please use `center_of_mass()`" - return self.center_of_mass() - def center_of_mass(self): """Get the center of mass of mesh.""" cmf = vtk.vtkCenterOfMass() @@ -3013,11 +2997,6 @@ def cmap( return self - @deprecated(reason=vedo.colors.red + "Please use property mesh.cellcolors" + vedo.colors.reset) - def cellIndividualColors(self, colorlist): - self.cellcolors = colorlist - return self - @deprecated(reason=vedo.colors.red + "Please use property mesh.cellcolors" + vedo.colors.reset) def cell_individual_colors(self, colorlist): self.cellcolors = colorlist @@ -3133,23 +3112,6 @@ def pointcolors(self, value): self.pointdata.select("PointsRGBA") - @deprecated(reason=vedo.colors.red + "Please use interpolate_data_from()" + vedo.colors.reset) - def interpolateDataFrom( - self, - source, - radius=None, - N=None, - kernel="shepard", - exclude=("Normals",), - on="points", - nullStrategy=1, - nullValue=0, - ): - "Deprecated. Please use `interpolate_data_from()`." - return self.interpolate_data_from( - source, radius, N, kernel, exclude, on, nullStrategy, nullValue - ) - def interpolate_data_from( self, source, @@ -3813,16 +3775,6 @@ def warp(self, source, target, sigma=1.0, mode="3d"): self.pipeline = utils.OperationNode("warp", parents=parents) return self - @deprecated(reason=vedo.colors.red + "Please use cut_with_plane()" + vedo.colors.reset) - def cutWithPlane(self, origin=(0, 0, 0), normal=(1, 0, 0)): - "Deprecated. Please use `cut_with_plane()`." - return self.cut_with_plane(origin, normal) - - @deprecated(reason=vedo.colors.red + "Please use cut_with_mesh()" + vedo.colors.reset) - def cutWithMesh(self, mesh, invert=False, keep=False): - "Deprecated. Please use `cut_with_mesh()`." - return self.cut_with_mesh(mesh, invert, keep) - def cut_with_plane(self, origin=(0, 0, 0), normal=(1, 0, 0), invert=False): """ Cut the mesh with the plane defined by a point and a normal. @@ -4994,7 +4946,7 @@ def _readPoints(): raise RuntimeError() dens.Update() pts = utils.vtk2numpy(dens.GetOutput().GetPoints().GetData()) - cld = Points(pts, c=None).pointSize(self.GetProperty().GetPointSize()) + cld = Points(pts, c=None).point_size(self.GetProperty().GetPointSize()) cld.interpolate_data_from(self, n=nclosest, radius=radius) cld.name = "densifiedCloud" diff --git a/vedo/shapes.py b/vedo/shapes.py index d845290e..a126b26d 100644 --- a/vedo/shapes.py +++ b/vedo/shapes.py @@ -1049,7 +1049,7 @@ def __init__(self, points, smooth=0.0, degree=2, closed=False, res=None, easing= - 0 = interpolate points exactly [default]. - 1 = average point positions. degree : (int) - degree of the spline (1