Toolbar Guide GUI Editor - Tool Creation - Brush

How can I include a brush tool onto my GUI? This is as far as I get
function uitoggletool_ClickedCallback(hObject, eventdata, handles)
brush(handles.clean_plot)
guidata(hObject, handles)
Many thanks, Will

 채택된 답변

Adam
Adam 2015년 3월 5일
편집: Adam 2015년 3월 5일

1 개 추천

function togglebutton1_Callback(hObject, eventdata, handles)
if hObject.Value == 1
brush( handles.figure1, 'on' );
else
brush( handles.figure1, 'off' );
end
seems to work fine for me using a toggle button. Strangely when I tested it at first on a scatter plot using the '*' marker it didn't work, but the same behaviour happened when I just tried on a normal normal figure so I don't know what is going in there. It worked when I used a 's' marker for my scatter plot though in both cases.
handles.figure1 is the tag for the figure itself. I never call mine 'figure1' when i am creating a proper GUI, but this was just a test so that is what it refers to. It must be the figure handle, not an axes handle.

댓글 수: 10

William
William 2015년 3월 5일
편집: William 2015년 3월 5일
It comes up with an error saying...
Attempt to reference field of non-structure array.
Error in GUI_name>uitoggletool6_clickedcallback (line ...)
if hObject.Value == 1
Adam
Adam 2015년 3월 5일
What is your full callback syntax?
Is this a GUI written using GUIDE or programmatically? My example was done using GUIDE, but the same idea should work programmatically, except that you obviously don't have a 'handles' structure and you don't have hObject either unless that is what you happened to name it in your created callback.
William
William 2015년 3월 5일
편집: William 2015년 3월 5일
it's in GUIDE (even tho I said programmatically at the top :L )
function uitoggletool6_ClickedCallback(hObject, eventdata, handles)
if hObject.Value == 1
brush( handles.clean_midline_plot, 'on' );
else
brush( handles.clean_midline_plot, 'off' );
end
If I look at the property inspector of the toolbar icon from the guide menu, it doesn't mention a "Value".
Adam
Adam 2015년 3월 5일
편집: Adam 2015년 3월 5일
Which version of Matlab are you using? I guess I should have used the old syntax to be sure:
if ( get( hObject, 'Value' ) == 1 )
should work in all versions of Matlab. The syntax I originally gave only works with R2014b onwards.
William
William 2015년 3월 5일
I'm on R2013a. Now it tells me the brush function finds the figure Unknown or invalid
Adam
Adam 2015년 3월 5일
편집: Adam 2015년 3월 5일
Is 'clean_midline_plot' a figure handle? It sounds more like an axes handle or an image or line object handle.
William
William 2015년 3월 6일
편집: William 2015년 3월 6일
yes, it's an axes handle. Would it be possible to create a new figure on guide to plot it into?
Adam
Adam 2015년 3월 6일
You can either create a new figure or use the figure containing your current axes handle. So long as you have the handle of whichever figure it is to be applied to it should work.
William
William 2015년 3월 6일
Because I have 2 other axes handles within this figure, so how to I choose a specific axes?
Think I'll just define a new figure and then save the brush data into the workspace shared by the original figure
Adam
Adam 2015년 3월 6일
As far as I know the brush will apply to all axes in a figure. I don't see an option to choose an axes for the brushing specifically. It isn't functionality I have ever used myself though, I'm just looking at the help page.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sung Hwan Heo
Sung Hwan Heo 2016년 3월 18일

0 개 추천

Do as follows//
function uitoggletool_brush_ClickedCallback(hObject, eventdata, handles)
if strcmp(get(handles.uitoggletool_brush, 'state'), 'on') brush( handles.figure1, 'on' ); else brush( handles.figure1, 'off' ); end guidata(hObject, handles);

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2015년 3월 4일

답변:

2016년 3월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by