Skip to content

Commit

Permalink
small bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Nov 30, 2023
1 parent ca390fa commit c4a0a56
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
6 changes: 5 additions & 1 deletion vedo/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -2842,7 +2842,7 @@ def Axes(
htitle_size=0.03,
htitle_font=None,
htitle_italic=False,
htitle_color=None,
htitle_color=None, htitle_backface_color=None,
htitle_justify='bottom-left',
htitle_rotation=0,
htitle_offset=(0, 0.01, 0),
Expand Down Expand Up @@ -2931,6 +2931,7 @@ def Axes(
- `htitle_font`, [None], header font (defaults to `title_font`)
- `htitle_italic`, [True], header font is italic
- `htitle_color`, [None], header title color (defaults to `xtitle_color`)
- `htitle_backface_color`, [None], header title color on its backface
- `htitle_justify`, ['bottom-center'], origin of the title justification
- `htitle_offset`, [(0,0.01,0)], control offsets of header title in x, y and z
- `xtitle_position`, [0.32], title fractional positions along axis
Expand Down Expand Up @@ -3927,6 +3928,9 @@ def Axes(
depth=title_depth,
italic=htitle_italic,
)
if htitle_backface_color is None:
htitle_backface_color = 1 - np.array(get_color(htitle_color))
htit.backcolor(htitle_backface_color)
htit.rotate_x(htitle_rotation)
wpos = [htitle_offset[0]*dx, (1 + htitle_offset[1])*dy, htitle_offset[2]*dz]
htit.shift(np.array(wpos) + [0, 0, xyshift*dz])
Expand Down
3 changes: 1 addition & 2 deletions vedo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,8 +1516,7 @@ def pos(self, x=None, y=None, z=None):
def shift(self, dx=0, dy=0, dz=0):
"""Add a vector to the current object position."""
if utils.is_sequence(dx):
utils.make3d(dx)
dx, dy, dz = dx
dx, dy, dz = utils.make3d(dx)
if dx == dy == dz == 0:
return self
LT = LinearTransform().translate([dx, dy, dz])
Expand Down
47 changes: 46 additions & 1 deletion vedo/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3512,7 +3512,9 @@ def user_mode(self, mode):

def close_window(self):
"""Close the current or the input rendering window."""
# https://examples.vtk.org/site/Cxx/Visualization/CloseWindow/
vedo.last_figure = None
self.last_event = None
self.sliders = []
self.buttons = []
self.widgets = []
Expand All @@ -3526,6 +3528,45 @@ def close_window(self):
if settings.dry_run_mode >= 2:
return self

# # print("Close window -------------")
# for r in self.renderers:
# r.RemoveAllObservers()

# if hasattr(self, "window") and self.window:
# if hasattr(self, "interactor") and self.interactor:
# # print("Close window1")

# self.interactor.ProcessEvents()
# self.interactor.SetInteractorStyle(None)
# self.interactor.RemoveAllObservers()
# self.interactor.ExitCallback()

# self.window.Finalize()

# self.interactor.SetRenderWindow(None)

# # print("Close window2")
# # try:
# # self.interactor.SetDone(True)
# # except AttributeError:
# # pass
# self.interactor.TerminateApp()
# # print("Close window3")
# # self.interactor = None

# # if hasattr(self, "interactor") and self.interactor:
# # if "Darwin" in vedo.sys_platform:
# # try:
# # self.interactor.ProcessEvents()
# # except:
# # pass
# self.interactor = None

# self.renderer = None # current renderer
# self.window = None
# # print("Close window4")

# PREVIUOS VERSION
for r in self.renderers:
r.RemoveAllObservers()
if hasattr(self, "window") and self.window:
Expand Down Expand Up @@ -3771,10 +3812,14 @@ def _keypress(self, iren, event):
x, y = iren.GetEventPosition()
renderer = iren.FindPokedRenderer(x, y)

if key in ["q", "Return", "Ctrl+q", "Ctrl+w", "Escape"]:
if key in ["q", "Return"]:
iren.ExitCallback()
return

elif key in ["Ctrl+q", "Ctrl+w", "Escape"]:
self.close()
return

elif key == "F1":
vedo.logger.info("Execution aborted. Exiting python kernel now.")
iren.ExitCallback()
Expand Down
3 changes: 3 additions & 0 deletions vedo/pointcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,9 @@ def closest_point(
If you want to reset it use `mymesh.point_locator=None`
and / or `mymesh.cell_locator=None`.
"""
if len(pt) != 3:
pt = [pt[0], pt[1], 0]

# NB: every time the mesh moves or is warped the locators are set to None
if ((n > 1 or radius) or (n == 1 and return_point_id)) and not return_cell_id:
poly = None
Expand Down

0 comments on commit c4a0a56

Please sign in to comment.