Azzera filtri
Azzera filtri

RBBOX problem

9 visualizzazioni (ultimi 30 giorni)
Silvia
Silvia il 15 Lug 2011
Risposto: Christophe il 10 Ott 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 Commento
David Fergenson
David Fergenson il 2 Lug 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

Accedi per commentare.

Risposte (2)

Paulo Silva
Paulo Silva il 15 Lug 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 Commenti
Silvia
Silvia il 15 Lug 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 il 15 Lug 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

Accedi per commentare.


Christophe
Christophe il 10 Ott 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 ?

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by