SGWindowButtonMotionFcn

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - User interface
Introduced first in SolidGeometry 4.9, Creation date: 2020-08-15, Last change: 2025-08-19

implements the concept of get(gca,'CurrentPoint') also for rotate3d on

Description

It seems that in 2019a in combination with some updates the behaviour of get(gca,'CurrentPoint') changed. It is not possible anymore within a ButtonDownFcn callback any other Currentpoint than the point of the first hit of the function. This is a problem for some function such as uipolygonmoveWindowButtonDownFcn. Therefor this function, if installed as WindowButtonMotionFcn callback creates a global variable named

get_gca_CurrentPoint which is the same as get(gca,'CurrentPoint')

but works also for rotate3D on.

See Also: , SGButtonDownFcn

Example Illustration

 missing image of SGWindowButtonMotionFcn(srch,cbdat)

Syntax

h=SGWindowButtonMotionFcn(srch,cbdat)

Input Parameter

srch:
cbdat:

Output Parameter

h: global variable get_gca_CurrentPoint

Examples


set(gcf,'WindowButtonMotionFcn',@SGWindowButtonMotionFcn);




Copyright 2020-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, SGWindowButtonMotionFcn, is designed to address a change in behavior observed in MATLAB 2019a regarding the get(gca,'CurrentPoint') function. The function is part of the SolidGeometry library and is used to track the current point in a graphical user interface, even when 3D rotation is enabled.

Input Parameters

Output Results

Function Workflow

  1. The function begins by declaring two global variables: get_gca_CurrentPoint2D and get_gca_CurrentPoint.
  2. It retrieves the current point from the current axes using get(gca,'CurrentPoint'), which returns a 2x3 matrix representing the 3D coordinates of the point.
  3. The first row of this matrix, which contains the 2D coordinates, is assigned to get_gca_CurrentPoint2D.
  4. The entire matrix is assigned to get_gca_CurrentPoint, capturing the full 3D coordinates.

This function is typically set as a callback for the WindowButtonMotionFcn property of a figure, allowing it to update the global variables whenever the mouse is moved within the figure window. This ensures that the current point is accurately tracked, even when 3D rotation is enabled.

Algorithm explaination created using ChatGPT on 2025-08-19 06:56. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21