Move a 2D object and track its position through a gui
Mostra commenti meno recenti
Hey everyone, i was wondering, is there a way to move a 2D object and track its new position after you have plotted them using your mouse. I dont want to draw a rectangle over an image as in some other questions i saw. What i want is, lets say i have two 2D objects
h1 = rectangle('Position',[0.59,0.35,3.75,1.37],...
'Curvature',[0.0,0.0],...
'LineWidth',2,'LineStyle','-',...
'FaceColor','g');
h2 = rectangle('Position',[1.59,5.35,2.75,4.37],...
'Curvature',[0.0,0.0],...
'LineWidth',2,'LineStyle','-',...
'FaceColor','g');
and a function that calculates the distance from their centers, i want do be able to move the one or the other using my mouse and the distance to be updated while i move them.
In my case i use this method to create some rectangles
for i = 1:compnum
rectangle('Position',[pos(i,1),pos(i,2),list(i,1),list(i,2)],...
'Curvature',[0,0],...
'LineWidth',2,'LineStyle','-')
daspect([1,1,1])
text(pos(i,1),pos(i,2),num2str(i))
end
where compos is a matrix that stores the position of the rectangles and list is a matrix with the dimentions they have.
Finally i use this code to print the distance of the two components
for i=1:compnum
text(compos(i,1),compos(i,2)+complist(i,2)/2,num2str(T(i)))
end
I thought it would be nice if i could merge all this into a single object and then be able to move it using my mouse.
Thanks in advance.
1 Commento
Raldi
il 10 Lug 2012
Risposte (0)
Categorie
Scopri di più su Map Display in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!