function flatten_buttons(command) %FLATTEN_BUTTONS Start the flatten uicontrols % % Copyright (c) 1995 by Claudio Rivetti and Mark Young % claudio@alice.uoregon.edu, mark@alice.uoregon.edu % global I Handlefig Handleimg B_frame Uibgcolor degree MapSize map c global degree_ed degree ind ed_zrange1 ed_zrange2 sl cdata sl_value vmin vmax z if strcmp(upper(command), 'START') if ~isimage setviewmode('TOPVIEW'); showimage; end set(ed_zrange1, 'style', 'text'); set(ed_zrange2, 'style', 'text'); if isempty(degree), degree=1; end cdata=get(Handleimg, 'cdata'); vmin=min(min(cdata)); vmax=max(max(cdata))+1; initbuttons('Image Flattening', 'Done', 'flatten_buttons(''DONE'');'); pos=get(B_frame, 'Position'); uiwidth=0.12; uithick=0.035; slw=0.02; slh=0.3; middle=pos(1)+(pos(3)-uiwidth)/2; z=zrange; sl_tx1=sprintf('%.2f', z(1)); sl_tx2=sprintf('%.2f', z(2)); degree_txpos = [middle, pos(2)+0.72, uiwidth, uithick]; degree_edpos = [middle, pos(2)+0.68, uiwidth, uithick]; exe_btpos = [middle, pos(2)+0.61, uiwidth, uithick]; undo_btpos = [middle, pos(2)+0.54, uiwidth, uithick]; rb_pos = [middle, pos(2)+0.47, uiwidth, uithick]; sl_txtpos = [pos(1)+(pos(3)-0.15)/2, pos(2)+0.40, 0.14, uithick]; sl_pos = [middle+0.027 pos(2)+0.09 slw, slh]; sl_tx1pos = [middle-0.025 pos(2)+0.09 0.05 0.03]; sl_tx2pos = [middle-0.025 pos(2)+0.06+slh 0.05 0.03]; sl_valuepos = [sl_pos(1)+slw+0.003, pos(2)+0.06+slh 0.1 0.03]; degree_edcbk='flatten_buttons(''SETDEGREE'');'; exe_btcbk='flatten_buttons(''EXECUTE'');'; undo_btcbk='flatten_buttons(''UNDO'');'; sl_cbk='flatten_buttons(''SLIDE'')'; rb_cbk='flatten_buttons(''SHOW'')'; slvalue_edcbk='flatten_buttons(''SETSLVALUE'')'; uicontrol(Handlefig, 'Style', 'text',... 'String', 'Pol. Degree',... 'Units', 'normalized',... 'Position', degree_txpos,... 'BackgroundColor', Uibgcolor); degree_ed = uicontrol(Handlefig, 'Style', 'edit',... 'String', num2str(degree),... 'value', degree,... 'Units', 'normalized',... 'Position', degree_edpos,... 'HorizontalAlignment', 'center',... 'CallBack', degree_edcbk); exe_bt=uicontrol(Handlefig, 'Style', 'push', ... 'String', 'Execute', ... 'Units', 'normalized', ... 'Interruptible', 'yes',... 'Position', exe_btpos, ... 'CallBack', exe_btcbk); undo_bt=uicontrol(Handlefig, 'Style', 'push', ... 'String', 'Undo', ... 'Units', 'normalized', ... 'Position', undo_btpos, ... 'CallBack', undo_btcbk); uicontrol(Handlefig, 'Style', 'push',... 'Units', 'normalized',... 'position', rb_pos,... 'String', 'Redraw',... 'CallBack', rb_cbk); uicontrol(Handlefig, 'Style', 'text',... 'String', 'Cut off height',... 'Units', 'normalized',... 'Position', sl_txtpos,... 'BackgroundColor', Uibgcolor); sl=uicontrol(Handlefig, 'Style', 'slide', ... 'Units', 'normalized', ... 'min', vmin,... 'max', vmax,... 'value', vmax,... 'Position', sl_pos, ... 'CallBack', sl_cbk); uicontrol(Handlefig, 'Style', 'text',... 'String', sl_tx1,... 'HorizontalAlignment', 'left',... 'Units', 'normalized',... 'Position', sl_tx1pos,... 'BackgroundColor', Uibgcolor); uicontrol(Handlefig, 'Style', 'text',... 'String', sl_tx2,... 'HorizontalAlignment', 'left',... 'Units', 'normalized',... 'Position', sl_tx2pos,... 'BackgroundColor', Uibgcolor); sl_value=uicontrol(Handlefig, 'Style', 'edit',... 'String', num2str((get(sl, 'value')-1)*(z(2)-z(1))/(vmax-vmin)+z(1)),... 'HorizontalAlignment', 'left',... 'Units', 'normalized',... 'Position', sl_valuepos,... 'HorizontalAlignment', 'center',... 'ForegroundColor', getpencolor,... 'CallBack', slvalue_edcbk); end % START if strcmp(upper(command), 'DONE') set(ed_zrange1, 'style', 'edit'); set(ed_zrange2, 'style', 'edit'); set(Handleimg, 'cdata', cdata); setmap(getmap); end % DONE if strcmp(upper(command), 'EXECUTE') setimage(doflatten(I, degree, ind)); cdata=get(Handleimg, 'cdata'); flatten_buttons('SLIDE'); end % EXECUTE if strcmp(upper(command), 'SHOW') c=cdata; ind=find(c>get(sl, 'value')); c(ind)=c(ind)*0+MapSize+1; colormap([colormap;getpencolor]); set(Handleimg, 'cdata', c); end % SHOW if strcmp(upper(command), 'SLIDE') flatten_buttons('SHOW'); drawnow set(sl_value, 'string', num2str((get(sl, 'value'))*(z(2)-z(1))/(vmax-vmin)+z(1)), 'Fore', getpencolor); end % SLIDE if strcmp(upper(command), 'SETDEGREE') editstr2value(degree_ed,0,5, 'int'); degree=get(degree_ed, 'value'); end % SETDEGREE if strcmp(upper(command), 'SETSLVALUE') editstr2value(sl_value,z(1),z(2)); set(sl, 'value', ((get(sl_value, 'value')-z(1))/(z(2)-z(1)))*(vmax-vmin)); flatten_buttons('SHOW'); end % SETLSVALUE if strcmp(upper(command), 'UNDO') undo; cdata=get(Handleimg, 'cdata'); end % UNDO return;