diff --git a/vedo/addons.py b/vedo/addons.py index 46e9c0c4..0ca66bdb 100644 --- a/vedo/addons.py +++ b/vedo/addons.py @@ -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), @@ -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 @@ -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]) diff --git a/vedo/core.py b/vedo/core.py index f17d4199..1fba2574 100644 --- a/vedo/core.py +++ b/vedo/core.py @@ -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]) diff --git a/vedo/plotter.py b/vedo/plotter.py index d0d82c2b..b8cc1562 100644 --- a/vedo/plotter.py +++ b/vedo/plotter.py @@ -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 = [] @@ -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: @@ -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() diff --git a/vedo/pointcloud.py b/vedo/pointcloud.py index b08d2a99..19e9ca1c 100644 --- a/vedo/pointcloud.py +++ b/vedo/pointcloud.py @@ -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