通行证│用户名: 密码: 验证码: 验证码,看不清楚?请点击刷新验证码 电信网通铁通移动   在线
资源搜索:
热门搜索:Linux VB C语言 PhotoShop Flash TCP/IP
   首页 | 文章 | 软件 | 动画 | 资源 | 励志 | 骗术 | 论坛 | 邮箱 | 会员中心 | 军事 | 科技 | 博客 | 图片 | 商城 | 最新更新 | 800g资源 | 爱心黑客
您现在的位置: 爱国者黑客 >> 资源 >> 机械电子 >> MATLAB >> Matlab基础 >> 文章正文
Matlab 图形用户界面设计工具
责任编辑:admin   更新日期:2005-8-6

11.6 图形用户界面设计工具


图 11.6-1

11.6.2 交互式用户界面设计工具应用示例


图 11.6.2-1 待制作的用户界面


11.6.2.1 工序一:窗口初始位置和大小设计
【例 11.6.2.1-1 】本例演示:界面设计工具 guide 的启动和用户界面窗口初试几何制作。


图 11.6.2.1-1 属性编辑工具界面

11.6.2.2 工序二:对象的几何布局

【例 11.6.2.2-1 】整个用户界面的几何布局:“轴”、控件种类、相对位置及大致尺寸。本例演示:( A )设计工具控制面板上“新对象模块区”的图标的使用;( B )几何布局时不必太多考虑各对象的精细位置和大小。


图 11.6.2.2-1 “第二道工序” 构成控件布局的界面


11.6.2.3 工序三:新建对象的属性设置
【例 11.6.2.3-1 】控件关键属性的设置。本例演示:
(A)属性编辑工具的使用。
(B)当 'Callback' 属性值可用比较简单的 MATLAB 语句表达时,则直接填写;如果语句较多,表达复杂,那么就应采用一个待写的 M 函数名填写。本例中的回调都借助 M 函数文件实现。
(C)当控件上有字符串标识时,应注意文字的对齐方式和注意字体大小,使外观上与对象大小协调。
(D)控件的 'String' 属性字符串的输入格式。在这过程中,可能还要适当调整对象几何尺寸,使字符表现清晰醒目。
(E) 'Units' 采用 'normalized' ,使得所有新建对象随所在图形窗按比例缩放。

11.6.2.4 工序四:用户菜单的制作
用户菜单制作工序比较独立,因此该工序可前可后,也可以与“工序一”相合并。

【例 11.6.2.4-1 】用户菜单的制作。本例演示:菜单编辑工具的使用。在本例中菜单引起的回调都是直接、简单的 MATLAB 语句。


图 11.6.2.4-1 用户菜单编辑器界面


11.6.2.5 工序五:新建图形对象的齐整化
【例 11.6.2.5-1 】控件的齐整化。本例演示:演示“对齐编辑工具”的使用。


图 11.6.2.5-1


11.6.2.6 工序六:回调函数的编写
【例 11.6.2.6-1 】回调函数的编写。本例演示:从处理方便出发编写回调函数。(关于回调函数的详细讨论,请看第 11.5 节的三个算例)

(1)弹出框的回调函数 Mycolormap.m
[Mycolormap.m]
function Mycolormap
popstr={ 'spring' , 'summer' , 'autumn' , 'winter' }; % 弹出框色图矩阵
vpop=get(findobj(gcf, 'Tag' , 'PopupMenu1' ), 'value' ); % 获得选项的位置标识
colormap(eval(popstr{vpop})) % 采用弹出框所选色图

(2)列表框和“ Apply ”按键配合的回调函数 Myapply.m
[Myapply.m]
function Myapply
vlist=get(findobj(gcf, 'Tag' , 'Listbox1' ), 'value' ); % 获得选项位置向量
liststr={ 'grid on' , 'box on' , 'hidden off' , 'axis off' }; % 列表框选项内容
invstr={ 'grid off' , 'box off' , 'hidden on' , 'axis on' }; % 列表框的逆指令
vv=zeros(1,4);vv(vlist)=1;
for k=1:4
if vv(k);eval(liststr{k}); else eval(invstr{k}); end % 按列表选项影响图形
end

(3)动态编辑框的回调函数 Myedit.m
[Myedit.m]
function Myedit
ct=get(findobj(gcf, 'Tag' , 'EditText1' ), 'string' );
eval(ct')


11.6.2.8 为读者提供的配套文件和数据
(1)机器自动生成的主控文件

[Mygui1.m]
function fig = Mygui1()
% This is the machine-generated representation of a Handle Graphics object
% and its children. Note that handle values may change when these objects
% are re-created. This may cause problems with any callbacks written to
% depend on the value of the handle at the time the object was saved.
% This problem is solved by saving the output as a FIG-file.%
% To reopen this object, just type the name of the M-file at the MATLAB
% prompt. The M-file and its associated MAT-file must be on your path.%
% NOTE: certain newer features in MATLAB may not have been saved in this
% M-file due to limitations of this format, which has been superseded by
% FIG-files. Figures which have been annotated using the plot editor tools
% are incompatible with the M-file/MAT-file format, and should be saved as
% FIG-files.

load Mygui1
h0 = figure( 'Units' , 'normalized' , ...
'Color' ,[0.8553876799929505 0.8553876799929505 0.8553876799929505], ...
'Colormap' ,mat0, ...
'FileName' , 'F:\99\m5\Mygui1.m' , ...
'MenuBar' , 'none' , ...
'Name' , 'GUI 工具设计的界面 ' , ...
'PaperPosition' ,[18 180 575.9999999999999 432], ...
'PaperUnits' , 'points' , ...
'Position' ,[0.1484375 0.5291666666666667 0.8 0.35], ...
'Tag' , 'Fig1' , ...
'ToolBar' , 'none' );
h1 = uimenu( 'Parent' ,h0, ...
'Label' , 'Zoom' , ...
'Tag' , 'M_Z' );
h2 = uimenu( 'Parent' ,h1, ...
'Callback' , 'zoom on' , ...
'Label' , 'On' , ...
'Tag' , 'M_Zon' );
h2 = uimenu( 'Parent' ,h1, ...
'Callback' , 'zoom off' , ...
'Label' , 'Off' , ...
'Tag' , 'M_Zoff' );

h1 = uicontrol( 'Parent' ,h0, ...
'Units' , 'normalized' , ...
'BackgroundColor' ,[0.7529411764706 0.7529411764706 0.7529411764706], ...
'Callback' , 'Mycolormap' , ...
'ListboxTop' ,0, ...
'Position' ,[0.80859375 0.773809523809524 0.16 0.130952380952381], ...
'String' ,[ 'spring ' ; 'summer ' ; 'autumn ' ; 'winter ' ], ...
'Style' , 'popupmenu' , ...
'Tag' , 'PopupMenu1' , ...
'Value' ,1);
h1 = uicontrol( 'Parent' ,h0, ...
'Units' , 'normalized' , ...
'BackgroundColor' ,[1 1 1], ...
'Max' ,2, ...
'Position' ,[0.80859375 0.327380952380952 0.16 0.398809523809524], ...
'String' ,[ 'grid on ' ; 'box on ' ; 'hidden off' ; 'axis off ' ], ...
'Style' , 'listbox' , ...
'Tag' , 'Listbox1' , ...
'Value' ,1);
h1 = uicontrol( 'Parent' ,h0, ...
'Units' , 'normalized' , ...
'BackgroundColor' ,[.752941176470588 .752941176470588 .752941176470588], ...
'Callback' , 'Myapply' , ...
'ListboxTop' ,0, ...
'Position' ,[0.80859375 0.12 0.16 0.15], ...
'String' , 'apply' , ...
'Tag' , 'Pushbutton1' );

h1 = uicontrol( 'Parent' ,h0, ...
'Units' , 'normalized' , ...
'BackgroundColor' ,[1 1 1], ...
'Callback' , 'Myedit' , ...
'FontName' , 'Times New Roman' , ...
'FontSize' ,10, ...
'HorizontalAlignment' , 'left' , ...
'ListboxTop' ,0, ...
'Max' ,2, ...
'Position' ,[.55078125 .3273809523809524 .232421875 .4523809523809523], ...
'Style' , 'edit' , ...
'Tag' , 'EditText1' );
h1 = axes( 'Parent' ,h0, ...

'CameraUpVector' ,[0 1 0], ...
'CameraUpVectorMode' , 'manual' , ...
'Color' ,[1 1 1], ...
'ColorOrder' ,mat1, ...
'Position' ,[0.05 0.15 0.45 0.65], ...
'Tag' , 'Axes1' , ...

'XColor' ,[0 0 0], ...
'YColor' ,[0 0 0], ...
'ZColor' ,[0 0 0]);
h2 = text( 'Parent' ,h1, ...
'Color' ,[0 0 0], ...
'HandleVisibility' , 'off' , ...
'HorizontalAlignment' , 'center' , ...
'Position' ,[0.4978165938864628 -0.2222222222222221 9.160254037844386], ...
'Tag' , 'Axes1Text4' , ...
'VerticalAlignment' , 'cap' );
set(get(h2, 'Parent' ), 'XLabel' ,h2);
h2 = text( 'Parent' ,h1, ...
'Color' ,[0 0 0], ...
'HandleVisibility' , 'off' , ...
'HorizontalAlignment' , 'center' , ...
'Position' ,[-0.1353711790393013 0.4907407407407408 9.160254037844386], ...
'Rotation' ,90, ...

[1] [2] 下一页

  • 上一篇文章:
  • 下一篇文章:
  • 热门文章
    Olldbg常见问题
    汇编语言的艺术(组合语言的艺术)--观
    汇编语言的艺术(组合语言的艺术)--准
    汇编语言的艺术(组合语言的艺术)--基
    汇编语言的艺术(组合语言的艺术)--基
    汇编语言---程式设计 (4)
    虚拟8086模式
    SYS命令使用说明
    javascript + CSS 实现动态菜单显
    推荐文章
    自制Windows XP SP2自动安装光盘
    SQLServer注入工具改进版 v1.02
    使用photoshop CS进行自然美肤
    Photoshop绘制诺基亚手机
    PHOTOSHOP制作秋日之梦
    PHOTOSHOP鼠绘名模王爱萍
    Photoshop制作晶莹飞溅的水珠
    教你用PHOTOSHOP做放大镜
    鼠绘美女及服装修画全过程