Point cloud rotate beyond plot limit (App Design based)

조회 수: 1 (최근 30일)
Veronica Taurino
Veronica Taurino 2022년 5월 2일
답변: Raghav Bansal 2023년 12월 28일
Hello!
My app has two panels: on the left data input, on the right plot results. My problem is: the plot can be rotated even when the mouse cursor appears on the left panel. How can i prevent this? The user could accidentally rotate the plot when changing input data.
The plot parent is a grid, children of the right panel.
Thank you

답변 (1개)

Raghav Bansal
Raghav Bansal 2023년 12월 28일
Hi Veronica,
To prevent the plot from rotating when the mouse is over the left panel, you can use the 'WindowButtonMotionFcn' callback of the figure to detect the cursor's position and disable the rotation if the cursor is over the left panel. You'll need to determine the boundaries of the left panel in the figure's coordinate system and then check if the cursor's position is within those boundaries.
Here's a step-by-step approach you can follow:
  1. Determine the position and size of the left panel: You can get this information from the Position property of the panel.
  2. Set up the 'WindowButtonMotionFcn' callback for the figure: This callback will be executed whenever the mouse moves within the figure window.
  3. In the callback function, check the cursor's position. Use the 'CurrentPoint' property of the figure to get the cursor's position.
  4. Compare the cursor's position to the left panel's boundaries. If the cursor is within the left panel, disable the rotation interaction on the plot; otherwise, enable it.
Hope it helps!
Regards,
Raghav

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by