Borrar filtros
Borrar filtros

RBBOX problem

9 visualizaciones (últimos 30 días)
Silvia
Silvia el 15 de Jul. de 2011
Respondida: Christophe el 10 de Oct. de 2019
Hello, I am using rbbox as this example:
point1 = get(gca,'CurrentPoint'); % button down detected
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint'); % button up detected
But if I look at point1 and point2 they are the same point,so it doesn't work correctly and I don't know why this is happening. Thank you very much
  1 comentario
David Fergenson
David Fergenson el 2 de Jul. de 2015
This may be a workaround for you if you aren't concerned as to which corner of the box was clicked first. Simply compute opposite corners using the values returned by rbbox into finalRect. One corner will be finalRect(1:2) and the other will be [finalRect(1)+finalRect(3), finalRect(2)+finalRect(4)];
Hope this helps. -Davio

Iniciar sesión para comentar.

Respuestas (2)

Paulo Silva
Paulo Silva el 15 de Jul. de 2011
You are using the code in a wrong way, you press and realease the button in the same point without moving the mouse.
Press the button, keep button pressed while moving the mouse away from point1, release the button, now point1 is diferent from point2.
k = waitforbuttonpress;
point1 = get(gca,'CurrentPoint') % button down detected
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint') % button up detected
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
p1 = min(point1,point2); % calculate locations
offset = abs(point1-point2); % and dimensions
x = [p1(1) p1(1)+offset(1) p1(1)+offset(1) p1(1) p1(1)];
y = [p1(2) p1(2) p1(2)+offset(2) p1(2)+offset(2) p1(2)];
hold on
axis manual
plot(x,y)
  2 comentarios
Silvia
Silvia el 15 de Jul. de 2011
Yes, my problem is that I'm moving the mouse. I press the button, keep button pressed while moving the mouse and I release the button. However both points are the same, it detects only first point and I do not know why.
Paulo Silva
Paulo Silva el 15 de Jul. de 2011
neither do I, try this
axes
ginput(2)
Click on two points of the axes and see if you get two diferent values or not

Iniciar sesión para comentar.


Christophe
Christophe el 10 de Oct. de 2019
Hello,
I have the same problems with Matlab R016b.
It is very frustrating because it is a random bug. It can works perfectly and soudainly fails with point1 and point2 egals.
Is there a workaround ?

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by