<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265116</link>
    <title>MATLAB Central Newsreader - GUI Current pointer location on displayed image</title>
    <description>Feed for thread: GUI Current pointer location on displayed image</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 05 Nov 2009 20:35:03 -0500</pubDate>
      <title>GUI Current pointer location on displayed image</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265116#692528</link>
      <author>Richard </author>
      <description>Ran into a little problem with my GUI program today.  I would like eventually to create lines and boxes on top of a displayed image.  Any help or reference to websites or functions would be much appreciated.&lt;br&gt;
&lt;br&gt;
Here's what I did if you are trying to recreate the problem.  Using guide create an axes tagged as Picture.  Then in the m-editor under the function that executes before figure is made visible, display a jpeg on the axes...&lt;br&gt;
&lt;br&gt;
axes(handles.Picture)&lt;br&gt;
image(imread('Picture.jpg'))  %loads and displays Picture.jpg&lt;br&gt;
&lt;br&gt;
Now I want to set up a click-able box using ButtonDownFcn or WindowButtonDownFcn(preferably the previous ButtonDownFcn) , WindowMotionFcn and WindowButtonUpFcn.&lt;br&gt;
&lt;br&gt;
I run into a problem with getting my mouse position on the image, &lt;br&gt;
&quot;There is no 'CurrentPoint' property in the 'image' class&quot;&lt;br&gt;
Seems like there should be a way of getting mouse location without ginput for an image because you can do it for a normal plot...&lt;br&gt;
I'm using 2007b btw</description>
    </item>
    <item>
      <pubDate>Sat, 07 Nov 2009 00:34:02 -0500</pubDate>
      <title>Re: GUI Current pointer location on displayed image</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265116#692829</link>
      <author>Richard </author>
      <description>&quot;Richard &quot; &amp;lt;rjtennant@greeneridge.com&amp;gt; wrote in message &amp;lt;hcvctn$4qa$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Ran into a little problem with my GUI program today.  I would like eventually to create lines and boxes on top of a displayed image.  Any help or reference to websites or functions would be much appreciated.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Here's what I did if you are trying to recreate the problem.  Using guide create an axes tagged as Picture.  Then in the m-editor under the function that executes before figure is made visible, display a jpeg on the axes...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; axes(handles.Picture)&lt;br&gt;
&amp;gt; image(imread('Picture.jpg'))  %loads and displays Picture.jpg&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Now I want to set up a click-able box using ButtonDownFcn or WindowButtonDownFcn(preferably the previous ButtonDownFcn) , WindowMotionFcn and WindowButtonUpFcn.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I run into a problem with getting my mouse position on the image, &lt;br&gt;
&amp;gt; &quot;There is no 'CurrentPoint' property in the 'image' class&quot;&lt;br&gt;
&amp;gt; Seems like there should be a way of getting mouse location without ginput for an image because you can do it for a normal plot...&lt;br&gt;
&amp;gt; I'm using 2007b btw&lt;br&gt;
&lt;br&gt;
I am pretty new to OOP and GUI programming and after a day more of research, I found a workable solution.  The point was realizing that the image was a child of the figure and the only child in this case, so get(get(gcf,'Children'),'CurrentPoint') gave me the current mouse position.  Hope this helps someone!</description>
    </item>
    <item>
      <pubDate>Sat, 07 Nov 2009 01:31:21 -0500</pubDate>
      <title>Re: GUI Current pointer location on displayed image</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265116#692836</link>
      <author>Richard </author>
      <description>&quot;Richard &quot; &amp;lt;rjtennant@greeneridge.DOTCOM&amp;gt; wrote in message &amp;lt;hd2f9q$p6q$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Richard &quot; &amp;lt;rjtennant@greeneridge.com&amp;gt; wrote in message &amp;lt;hcvctn$4qa$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Ran into a little problem with my GUI program today.  I would like eventually to create lines and boxes on top of a displayed image.  Any help or reference to websites or functions would be much appreciated.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Here's what I did if you are trying to recreate the problem.  Using guide create an axes tagged as Picture.  Then in the m-editor under the function that executes before figure is made visible, display a jpeg on the axes...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; axes(handles.Picture)&lt;br&gt;
&amp;gt; &amp;gt; image(imread('Picture.jpg'))  %loads and displays Picture.jpg&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Now I want to set up a click-able box using ButtonDownFcn or WindowButtonDownFcn(preferably the previous ButtonDownFcn) , WindowMotionFcn and WindowButtonUpFcn.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I run into a problem with getting my mouse position on the image, &lt;br&gt;
&amp;gt; &amp;gt; &quot;There is no 'CurrentPoint' property in the 'image' class&quot;&lt;br&gt;
&amp;gt; &amp;gt; Seems like there should be a way of getting mouse location without ginput for an image because you can do it for a normal plot...&lt;br&gt;
&amp;gt; &amp;gt; I'm using 2007b btw&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I am pretty new to OOP and GUI programming and after a day more of research, I found a workable solution.  The point was realizing that the image was a child of the figure and the only child in this case, so get(get(gcf,'Children'),'CurrentPoint') gave me the current mouse position.  Hope this helps someone!&lt;br&gt;
&lt;br&gt;
oooh my goodness i just solved my problem!&lt;br&gt;
Well I was trying to draw a box on an image, and was almost gonna give up but... discovered waitforbuttonpress, because I was having problems with WindowButtonMotionFcn trumping every other callback in the queue.&lt;br&gt;
So anyways, kinda a weak solution but here it is.&lt;br&gt;
&lt;br&gt;
my start box function is what is executed on ButtonDownFcn&lt;br&gt;
function StartBox(obj,evnt)&lt;br&gt;
pt=get(get(gcf,'Children'),'CurrentPoint')&lt;br&gt;
h=line('Xdata', pt(1,1),'Ydata',pt(1,2))&lt;br&gt;
set(f,'WindowButtonMotion', {@DrawBox,h,pt})&lt;br&gt;
waitforbuttonpress&lt;br&gt;
set(f,'WindowButtonMotion', '')&lt;br&gt;
&lt;br&gt;
Where the DrawBox function just gets the current points in the same way and sets the x &amp; y data.  &lt;br&gt;
&lt;br&gt;
So when button is pressed, it draws initial point, then DrawBox takes over which is constantly refreshed and does the fancy stuff, but next time a button is pressed, in my case when I want to close the box, the StartBox finishes executing and stops any motion function.  Cool Beans</description>
    </item>
  </channel>
</rss>

