1 / 19

第六课 GUI 编制

第六课 GUI 编制. 句柄图形体系 GUI 制作. 句柄图形体系. 高层图形指令 plot , mesh 底层图形指令 句柄操作 操纵底层的基本绘图要素 更灵活更细致的表现数据和图形. 句柄的含义. 句柄图形对象:用于数据可视和界面制作的基本绘图要素。 句柄:每个具体对象的 “ 与生俱来、终身不变 ” 的身份认证( Identifier )。 句柄唯一标识了图形对象,不同对象的句柄不可能重复和混淆。 每个图形必有的句柄: 根屏幕和图形窗(图). 根屏幕对象和图形窗对象. 根屏幕对象 根对象的唯一性 句柄号为 0 图形窗对象 可以有多个

serena
Download Presentation

第六课 GUI 编制

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第六课 GUI编制 句柄图形体系 GUI制作

  2. 句柄图形体系 • 高层图形指令 • plot,mesh • 底层图形指令 • 句柄操作 • 操纵底层的基本绘图要素 • 更灵活更细致的表现数据和图形

  3. 句柄的含义 • 句柄图形对象:用于数据可视和界面制作的基本绘图要素。 • 句柄:每个具体对象的“与生俱来、终身不变”的身份认证(Identifier)。 • 句柄唯一标识了图形对象,不同对象的句柄不可能重复和混淆。 • 每个图形必有的句柄: • 根屏幕和图形窗(图)

  4. 根屏幕对象和图形窗对象 • 根屏幕对象 • 根对象的唯一性 • 句柄号为0 • 图形窗对象 • 可以有多个 • 句柄号为正整数 • 其他对象的句柄号为双精度浮点数 • 不能通过直接赋值的方式建立句柄

  5. 句柄图形体系 Root 根屏幕 Figure 图 Uicontrols 界面控件 Axes 轴 Uimenu 界面菜单 。。。 。。。 。。。

  6. 对象句柄的获取方法 • 从图形创建指令获取句柄 • 追溯法 • 获取当前句柄对象 • 搜索法 • 标签法

  7. 从图形创建指令获取句柄 • h = figure; • h = plot(…); • h = mesh(…);

  8. 追溯法 • h_pa = get(h_now,’Parent’); • h_ch = get(h_now,’Children’);

  9. 获取当前句柄对象 • gcf:返回当前图形窗口的句柄 • gca:返回当前轴的句柄 • gco:返回鼠标最近点击的图形对象句柄

  10. 搜索法 • h = findobj('P1Name', P1Value) • h = findobj(h_ob,'P1Name', P1Value)

  11. 标签法 • plot(x,y,’Tag’,’A4’) • plot(x,y); set(gca,’Tag’,’A4’); • h_ax = findobj(0, ’Tag’,’A4’)

  12. 对象属性的获取和设置 • get(H): • 获取H句柄对象所有属性的当前值 • get(H,pn) • set(H) • 显示H所有可设置属性名和全部供选属性值 • set(H,pn) • set(gcf,’pointer’,’circle’);

  13. GUI制作 • clf reset • H = axes('unit','normalized','position',[0,0,1,1],'visible','off'); • set(gcf,'currentaxes',H); • str = '\fontname{隶书}归一化二阶系统的阶跃响应曲线'; • text(0.12,0.93,str,'fontsize',13); • h_fig = get(H,'parent'); • set(h_fig,'unit','normalized','position',[0.1,0.2,0.7,0.4]); • h_axes = axes('parent',h_fig,... • 'unit','normalized','position',[.1,.15,.55,.7],... • 'xlim',[0 15],'ylim',[0 1.8],'fontsize',8);

  14. h_text=uicontrol(h_fig,'style','text',... • 'unit','normalized','position',[0.67,0.73,0.25,0.14],... • 'horizontal','left','string',{'输入阻尼比系数','zeta ='}); • h_edit=uicontrol(h_fig,'style','edit',... • 'unit','normalized','position',[0.67,0.59,0.25,0.14],... • 'horizontal','left',... • 'callback',[... • 'z=str2num(get(gcbo,''string''));',... • 't=0:0.1:15;',... • 'for k=1:length(z);',... • 'y(:,k)=step(1,[1 2*z(k) 1],t);',... • 'plot(t,y(:,k));',... • 'if (length(z)>1) ,hold on,end,',... • 'end;',... • ‘hold off,‘]);

  15. h_push1=uicontrol(h_fig,'style','push',... • 'unit','normalized','position',[0.67,0.37,0.12,0.15],... • 'string','grid on','callback','grid on'); • h_push2=uicontrol(h_fig,'style','push',... • 'unit','normalized','position',[0.67,0.15,0.12,0.15],... • 'string','grid off','callback','grid off');

  16. 交互式用户界面设计 • 10.3 界面菜单(uimenu) • 10.4 用户控件(uicontrol) • 10.6 图形用户界面设计工具

  17. 界面菜单(uimenu) • 获取缺省设置的标准菜单 • hFig = figure; • 隐去和恢复标准菜单 • set(hFig, ‘menubar’,’none’); • set(hFig,’menubar’,’figure’); • 自制用户菜单

  18. 自制用户菜单 • hMenu = uimenu(gcf,’label’,’Color’); • h_submenu1=uimenu(hMenu,'label','Blue',... • 'callback','set(gcf,''Color'',''blue'')'); • h_submenu2=uimenu(hMenu,'label','Red',... • 'callback','set(gcf,''Color'',''red'')');

  19. 用户控件(uicontrol) • 图形用户界面设计工具 • Command Window: guide

More Related