Change imellipse position when the string in edit-text uicontrol is updated.

1 Ansicht (letzte 30 Tage)
Hi All,
I rather have a strange requirement. I display an image in an axes of a GUI figure created using GUIDE. I use imellipse to select a circle in the image. Although imellipse allows me to resize it by dragging the boundaries, I also want to resize it based on the vector entered in the uicontrol edit-text.
Essentially, when imellipse is run, a popup window with edit-text uicontrol is created with some initial position vector of the ellipse. I want to change the position vector in the edit-text which gets reflected in the position of ellipse in the image and also that the resizing of imellipse updates the vector in edit-text.
I was able to do the latter part using the following lines of code (under a function called crop) -
EllipseHandle = imellipse(gca,[0.25*width 0.25*height 0.5*width 0.5*height]);
addNewPositionCallback(EllipseHandle,@(p) set(handles.CroppingVector,'String',num2str(p,3)));
CroppingVector is the tag for the edit-text uicontrol.
Now, I want to update the position of the ellipse when the vector in edit-text is changed. I am able to read the updated vector in the callback function for edit-text which looks like this:
function CroppingVector_Callback(hObject, eventdata, handles)
% hObject handle to CroppingVector (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Pos = str2num(get(handles.CroppingVector,'String'));
However, I am having difficulty trying to understand how to update the ellipse position. I tried using (immediately after above line of code in the callback function for edit-text)
setConstrainedPosition(EllipseHandle,Pos);
But I get the following error
Undefined function 'setConstrainedPosition' for input arguments of type 'double'.
Obviously, EllipseHandle is not recognized. Can anyone please suggest a working solution to my problem?
-- Thanks, Ram.

Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by