Coordinates related to rbbox in GUI

3 visualizaciones (últimos 30 días)
Lin
Lin el 17 de Mayo de 2011
I programmed a GUI where there is a Axes in it. I try to select some objects in this Axes using rbbox.
The problem is that the return vector of rbbox is measured from the coordinate of whole GUI instead of the coordinate of Axes. How can I get the return vector whos reference coordinate is Axes in Gui?
Thank you in advance. Lin

Respuesta aceptada

Matt Fig
Matt Fig el 17 de Mayo de 2011
You could just do like the example in RBBOX, and use the currentpoint property of the axes instead...
figure;
pcolor(peaks);
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,'r','linewidth',5) % draw box around selected region
  2 comentarios
Lin
Lin el 17 de Mayo de 2011
Thank you very much
B_Richardson
B_Richardson el 7 de Jul. de 2011
How can this be modified to allow multiple selections?

Iniciar sesión para comentar.

Más respuestas (0)

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