Hello,
I have an image displayed via imshow from the image processing toolbox. Since my image is in front of the axes1 I'm not able to use the 'ButtonDownFcn' of my axes. Hence, I define a 'ButtonDownFcn' for my image in the 'OpeningFcn' of my figure:
axH = handles.axes1;
image = imread([pathname,filename]);
imshow(image,'Parent',axH);
handles.image = get(axH,'Children');
set(handles.image,'ButtonDownFcn',{@axes1_ButtonDownFcn,handles});
% Update handles structure
guidata(hObject, handles);
In the 'axes1_ButtonDownFcn' of the image, I try to add some additional handles to the handles structure and save it back to handles:
handles.marker1 = marker;
guidata(hObject, handles);
In the next call of my 'axes1_ButtonDownFcn', the previously added handle is not included in handles, why?
Does anybody know why the handles structure is not updated???
|
|
0
|
|
|
|
Reply
|
Johannes
|
9/7/2010 1:02:25 PM |
|
"Johannes " <J.Ruhhammer@gmx.de> wrote in message
news:i65d51$qku$1@fred.mathworks.com...
> Hello,
>
> I have an image displayed via imshow from the image processing toolbox.
> Since my image is in front of the axes1 I'm not able to use the
> 'ButtonDownFcn' of my axes.
Set the HitTest property of your image to 'off'.
> Hence, I define a 'ButtonDownFcn' for my image in the 'OpeningFcn' of my
> figure:
>
> axH = handles.axes1;
> image = imread([pathname,filename]);
> imshow(image,'Parent',axH);
> handles.image = get(axH,'Children');
> set(handles.image,'ButtonDownFcn',{@axes1_ButtonDownFcn,handles});
This sets the ButtonDownFcn to contain a cell array, the first element of
which is a function handle and the second is a copy of the handles structure
_at the time this SET call executes_. Note that this COPY does NOT update
as the master copy does; it's fixed until or unless you modify the
ButtonDownFcn for the image.
> % Update handles structure
> guidata(hObject, handles);
>
> In the 'axes1_ButtonDownFcn' of the image, I try to add some additional
> handles to the handles structure and save it back to handles:
>
> handles.marker1 = marker;
> guidata(hObject, handles);
>
> In the next call of my 'axes1_ButtonDownFcn', the previously added handle
> is not included in handles, why?
See above. If changing the HitTest property is not sufficient, use GUIDATA
inside the callback with the first input argument (the handle of the object
whose callback is executing) as the input to create a copy of the "master"
handles structure in the callback workspace, modify that copy, and call
GUIDATA again to update the master copy.
--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
|
|
0
|
|
|
|
Reply
|
slord (13279)
|
9/7/2010 1:08:28 PM
|
|
"Steven_Lord" <slord@mathworks.com> wrote in message
> >
> > I have an image displayed via imshow from the image processing toolbox.
> > Since my image is in front of the axes1 I'm not able to use the
> > 'ButtonDownFcn' of my axes.
>
> Set the HitTest property of your image to 'off'.
Hi Steven,
thanks for your fast reply. I tried to set the HitTest property to 'off' but it didn't work. My underlying axes still doesn't recognize a button click (when I remove the image, everything works fine). Do you know why?
The other thing worked perfectly:
.... ButtonDownFcn...
handles = guidata(hObject)
....
....
guidata(hObject, handles);
Thanks for that!
|
|
0
|
|
|
|
Reply
|
Johannes
|
9/7/2010 1:30:28 PM
|
|
|
2 Replies
304 Views
(page loaded in 0.028 seconds)
Similiar Articles: Using Handles structure with ButtonDownFcn - comp.soft-sys.matlab ...Hello, I'm creating a GUI using GUIDE, and I have run into a problem where the handles structure is not ... src); % some operations % Update handles structure guidata ... Locating GUIDE Gui Figure Handle/Passing Data - comp.soft-sys ...So, what I'm looking for is a way to update the gui.m handles from function.m ... Inside gui.m, are you re-executing handles = guidata(gcf); ? If not, then although ... GUI, timer, handles - comp.soft-sys.matlab... readSerial is the following function readSerial(obj, event, hObject) handles = guidata(hObject); % I try to retrieve updated handles with this % other stuff not ... GUIDE gui handles visibility to user defined function - comp.soft ...thanks walter how am I suppose to specify how to see my Main gui's handles( to see guidata of my main gui) while executing this function. timer function in GUIDE - comp.soft-sys.matlabI would instead store the handle of the GUI figure in the UserData and use GUIDATA inside your timer ... function refresh > > some stuff using handles, updating display ... live video handles is run in other axes when doing process of ...'handles=guidata(gcf);'... % Update handles 'image(getsnapshot(handles.video));'... % Get picture using GETSNAPSHOT and put it into axes using IMAGE 'set(handles ... Stop running program without exiting current GUI - comp.soft-sys ...... in a future version of MATLAB > % handles structure with handles and user data (see GUIDATA) > handles.output = hObject; > > % Update handles structure > guidata ... How to access changed GUI handle data in OutputFcn? - comp.soft ...Stop running program without exiting current GUI - comp.soft-sys ..... if you want to update the data in your Gui > % guidata(hObject, handles ... Guide: Set handles out of closerequestfcn - comp.soft-sys.matlab ...Next step was to try to pass the handles by using guidata... without success. So the question is: Is there a way to edit the handles struct within the closerequestfcn ... increase or decrase brightness of an image - comp.soft-sys.matlab ...... handles structure with handles and user data (see GUIDATA) handles ... You're not applying the colormap at all. Try using the colormap() function, passing it the ... guidata - Store or retrieve GUI data - MathWorks - MATLAB and ...Description. guidata(object_handle,data) stores the variable data as GUI data. If object_handle is not a figure handle, then the object's parent figure is used. guidata not updating handles? - Newsreader - MATLAB CentralMATLAB Central > MATLAB Newsreader > guidata not updating handles? ... I have a small function in my GUIDE-created gui's OpeningFcn which ... 7/25/2012 4:04:55 AM
|