Effacer les filtres
Effacer les filtres

RBBOX problem

9 vues (au cours des 30 derniers jours)
Silvia
Silvia le 15 Juil 2011
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 commentaire
David Fergenson
David Fergenson le 2 Juil 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

Connectez-vous pour commenter.

Réponses (2)

Paulo Silva
Paulo Silva le 15 Juil 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 commentaires
Silvia
Silvia le 15 Juil 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 le 15 Juil 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

Connectez-vous pour commenter.


Christophe
Christophe le 10 Oct 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 ?

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by