Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
17
Добавлен:
09.02.2015
Размер:
257.02 Кб
Скачать

matlab\uitools – Инструменты графического интерфейса пользователя

GUI functions

<uicontrol> - Create user interface control.

UICONTROL Create user interface control.

UICONTROL('PropertyName1',value1,'PropertyName2',value2,...)

creates a user interface control in the current figure

window and returns a handle to it.

UICONTROL(FIG,...) creates a user interface control in the

specified figure.

UICONTROL properties can be set at object creation time using

PropertyName/PropertyValue pair arguments to UICONTROL, or

changed later using the SET command.

Execute GET(H) to see a list of UICONTROL object properties and

their current values. Execute SET(H) to see a list of UICONTROL

object properties and legal property values. See a reference

guide for more information.

Examples:

Example 1:

%creates uicontrol specified in a new figure

uicontrol('Style','edit','String','hello');

Example 2:

%creates three figures and only puts uicontrol in the second figure

fig1 = figure;

fig2 = figure;

fig3 = figure;

uicontrol('Parent', fig2, 'Style', 'edit','String','hello');

See also set, get, uimenu.

Reference page in Help browser

doc uicontrol

<uimenu> - Create user interface menu.

UIMENU Create user interface menu.

UIMENU('PropertyName1',value1,'PropertyName2',value2,...) creates

a menu on the menu bar at the top of the current figure window,

and returns a handle to it.

UIMENU(H,...) creates a new menu with H as a parent. H must be a

figure handle, menu handle, or context menu handle. If H is a

figure handle, UIMENU creates a menu on the menu bar at the top

of the window. If H is handle to a menu on the menu bar, the new

menu is a menu item beneath the parent item on the menu bar. If

H is a handle to a menu item, UIMENU creates a walking menu beneath

the menu item. If H is a handle to a context menu, the new menu is

a menu item on the context menu.

Menu properties can be set at object creation time using

PropertyName/PropertyValue pair arguments to UIMENU, or changed

later using the SET command.

Execute GET(H) to see a list of UIMENU object properties and

their current values. Execute SET(H) to see a list of UIMENU

object properties and legal property values. See a reference

guide for more information.

See also set, get, uicontrol, uicontextmenu.

Reference page in Help browser

doc uimenu

<dragrect> - Drag XOR rectangles with mouse.

DRAGRECT Drag XOR rectangles with mouse.

DRAGRECT(RECTS) allows the rectangles specified in the

N-by-4 matrix RECTS to be dragged with the mouse while a mouse

button is down. Rectangles can be dragged anywhere on the

screen.

DRAGRECT(RECTS, STEPSIZE) moves the rectangles only in increments

of STEPSIZE. The lower-left corner of the first rectangle

Is constrained to the grid of size stepsize starting at the

lower-left corner of the figure, and all other rectangles

maintain their original offset from the first rectangle.

RECTS2=DRAGRECT(...) returns the final positions of the rectangles

specified in RECTS when the mouse button is released.

Each row of RECTS must contain the initial rectangle position

as [left bottom width height]. DRAGRECT returns the final

position of the rectangles. If the drag ends over a

figure window, the positions of the rectangles are

returned in that figure's coordinate system. If the drag ends

over a part of the screen not contained within a figure window,

the rectangles are returned in the coordinate system of the

figure over which the drag began. DRAGRECT returns immediately

If a mouse button is not down.

Note that you cannot use normalized figure units with DRAGRECT.

Examples:

dragrect(BoxPos);

dragrect(BoxPos, 2.0);

NewBoxPos=dragrect(BoxPos);

See also rbbox.

Reference page in Help browser

doc dragrect

<ginput> - Graphical input from mouse.

GINPUT Graphical input from mouse.

[X,Y] = GINPUT(N) gets N points from the current axes and returns

the X- and Y-coordinates in length N vectors X and Y. The cursor

can be positioned using a mouse. Data points are entered by pressing

a mouse button or any key on the keyboard except carriage return,

which terminates the input before N points are entered.

[X,Y] = GINPUT gathers an unlimited number of points until the

return key is pressed.

[X,Y,BUTTON] = GINPUT(N) returns a third result, BUTTON, that

contains a vector of integers specifying which mouse button was

used (1,2,3 from left) or ASCII numbers if a key on the keyboard

was used.

Examples:

[x,y] = ginput;

[x,y] = ginput(5);

[x, y, button] = ginput(1);

See also gtext, waitforbuttonpress.

Reference page in Help browser

doc ginput

<selectmoveresize> - Interactively select, move, resize, or copy objects.

SELECTMOVERESIZE Interactively select, move, resize, or copy objects.

SELECTMOVERESIZE as a button down function will handle selecting,

moving, resizing, and copying of Axes and Uicontrol graphics objects.

A = SELECTMOVERESIZE returns a structure array containing the following

fields:

Type - a string containing the action type, which can be Select,

Move, Resize, or Copy.

Handles - A list of the selected handles or for a Copy an Nx2 matrix

containing the original handles in the first column and the new

handles in the second column.

Example:

This sets the button down function of the current axes to SELECTMOVERESIZE:

ax = axes;

set(ax,'ButtonDownFcn','selectmoveresize');

See also pan, rotate, rotate3d, zoom.

Reference page in Help browser

doc selectmoveresize

<uipanel> - Uipanel container object.

UIPANEL Uipanel container object.

UIPANEL adds a uipanel container object to the current figure.

If no figure exists, one will be created. Uipanel objects can have

the same child objects as a figure, excepting toolbars and menus.

In addition, uipanel objects can have

additional instances of uipanels as children. This allows a multiple

nested tree of objects rooted at the figure.

Uipanels have properties to control the appearance of borders

and titles.

Execute GET(H), where H is a uipanel handle, to see a list of uipanel

object properties and their current values. Execute SET(H) to see a

list of uipanel object properties and legal property values.

Example:

h = figure;

hp = uipanel('Title','Main Panel','FontSize',12,...

'BackgroundColor','white',...

'Position',[.25 .1 .67 .67]);

hsp = uipanel('Parent',hp,'Title','Subpanel','FontSize',12,...

'Position',[.4 .1 .5 .5]);

hbsp = uicontrol('Parent',hsp,'String','Push here',...

'Position',[18 18 72 36]);

See also hgtransform.

Reference page in Help browser

doc uipanel

<uiresume> - Resume execution of blocked M-file.

UIRESUME Resume execution of blocked MATLAB code.

UIRESUME(FIG) resumes the MATLAB code execution that was suspended by a UIWAIT(FIG) command. UIRESUME is a companion function to UIWAIT.

Example:

f = figure;

h = uicontrol('Position', [20 20 200 40], 'String', 'Continue', ...

'Callback', 'uiresume(gcbf)');

disp('This will print immediately');

uiwait(gcf);

disp('This will print after you click Continue'); close(f);

See also uiwait, waitfor.

Reference page in Help browser

doc uiresume

<uistack> - Reorder the visual stacking order of objects.

UISTACK Reorder the visual stacking order of objects.

UISTACK(H) raises the visual stacking order of the objects specified by

the handles in H by one level (STEP of 1).

UISTACK(H, STACKOPT) where STACKOPT is 'up', 'down', 'top' or 'bottom'

specifies how to stack the objects specified by the handles in H.

UISTACK(H, STACKOPT, STEP) where STEP is the distance to move 'up' or

'down' applies the stacking option to the objects specified by the

handles in H. All handles in H must have the same parent.

Example:

OriginalColorOrder='rgbyc';

Expected_Color531top='ygrbc';

close all force;

Fig=figure('color','black');

for lp=1:5,

Orig_order(lp,1)=axes('Color' ,OriginalColorOrder(lp), ...

'Position',[.15*(lp-1) .15*(lp-1) .4 .4], ...

'XTick',[], ...

'YTick',[], ...

'Tag',OriginalColorOrder(lp));

end

%these blocks should be stacked in order 5, 3, 1

Tmp_order=uistack(Orig_order([5 3 1]),'top');

index=1;

ActualColorOrder9='';

for lp=1:size(Tmp_order,1);

if strcmp(get(Tmp_order(lp),'Type'),'axes'),

New_order(index)=Tmp_order(lp);

ActualColorOrder9=[get(New_order(index),'Tag'),ActualColorOrder9];

index=index+1;

end

end

See also align, uicontrol, uipanel

Reference page in Help browser

doc uistack

<uiwait> - Block execution and wait for resume.

UIWAIT Block execution and wait for resume.

UIWAIT(FIG) blocks execution until either UIRESUME is called or the

figure FIG is destroyed (closed). UIWAIT with no input arguments is

the same as UIWAIT(GCF).

UIWAIT(FIG, TIMEOUT), in addition to the previous syntax, blocks

execution until either TIMEOUT seconds elapse or one of the

previous return conditions is met. TIMEOUT value cannot be less than

one second. In case the TIMEOUT value entered is less than one second

that particular value will not be used and a TIMEOUT value of one

second will be used.

When the dialog or figure is created, it should have a

uicontrol that either:

has a callback that calls UIRESUME, or

has a callback that destroys the dialog box

since these are the only methods that can resume program execution

after it has been suspended by the waitfor command.

UIWAIT is a convenient way to use the waitfor command and is used in

conjunction with a dialog box or figure. When used with a modal

dialog (which captures all keyboard and mouse events), it provides a

way to suspend a MATLAB code and prevent the user from accessing any

MATLAB window until they respond to the dialog box.

Examples:

f = figure;

h = uicontrol('Position', [20 20 200 40], 'String', 'Continue', ...

'Callback', 'uiresume(gcbf)');

disp('This will print immediately');

uiwait(gcf);

disp('This will print after you click Continue'); close(f);

See also uiresume, waitfor.

Reference page in Help browser

doc uiwait

<waitfor> - Block execution and wait for event.

WAITFOR Block execution and wait for event.

WAITFOR(H) returns when the graphics object identified by H

is deleted or when Ctrl-C is typed in the Command Window. If H does

not exist, waitfor returns immediately without processing any events.

WAITFOR(H,'PropertyName'), in addition to the conditions in the

previous syntax, returns when the value of 'PropertyName' for the

graphics object H changes. If 'PropertyName' is not a valid property

for the object, waitfor returns immediately without processing

any events.

WAITFOR(H,'PropertyName',PropertyValue), in addition to the

conditions in the previous syntax, returns when the value of

'PropertyName' for the graphics object H changes to PropertyValue.

If 'PropertyName' is set to PropertyValue, waitfor returns

immediately without processing any events.

While waitfor blocks an execution stream, it processes events as

would drawnow, allowing callbacks to execute. Nested calls to

waitfor are supported, and earlier calls to waitfor will not return

until all later calls have returned, even if the condition upon which

the earlier call is blocking has been met.

Examples:

f = warndlg('This is a warning.', 'A Warning Dialog');

disp('This prints immediately');

waitfor(f);

disp('This prints after the warning dialog is closed');

f = figure('Name', 'My Figure');

h = uicontrol('String', 'Change Name', 'Position', [20 20 200 40], ...

'Callback', 'set(gcbf, ''Name'', num2str(rand(1)))');

disp('This prints immediately');

waitfor(f, 'Name');

disp('This prints after the button is clicked to change the figure''s name');

close(f);

f = figure;

textH = text(.5, .5, 'Hello');

set(textH,'Editing','on');

disp('This prints immediately');

waitfor(textH,'Editing','off');

disp('This prints after text editing is complete');

close(f);

Overloaded methods:

timer/waitfor

Reference page in Help browser

doc waitfor

<waitforbuttonpress> - Wait for key/buttonpress over figure.

WAITFORBUTTONPRESS Wait for key/buttonpress over figure.

T = WAITFORBUTTONPRESS stops program execution until a key or

mouse button is pressed over a figure window. Returns 0

when terminated by a mouse buttonpress, or 1 when terminated

by a keypress. Additional information about the terminating

event is available from the current figure.

Example:

f = figure;

disp('This will print immediately');

keydown = waitforbuttonpress;

if (keydown == 0)

disp('Mouse button was pressed');

else

disp('Key was pressed');

end

close(f);

See also ginput, gcf.

Reference page in Help browser

doc waitforbuttonpress

GUI design tools

<align> - Align uicontrols and axes.

ALIGN Align uicontrols and axes.

ALIGN(HandleList,HorizontalAlignment,VerticalAlignment) will

align the objects in the handle list. Adding a left hand argument

will cause the updated positions of the objects to be returned while

the position of the objects on the figure does not change.

Calling the alignment tool with

Positions=ALIGN(CurPositions,HorizontalAlignment,VerticalAlignment)

will return the updated position matrix from the initial position

matrix.

Possible values for HorizontalAlignment are:

None, Left, Center, Right, Distribute, Fixed

Possible values for VerticalAlignment are:

None, Top, Middle, Bottom, Distribute, Fixed

All alignment options will align the objects within the

bounding box that encloses the objects. Distribute and Fixed

will align objects to the bottom left of the bounding box. Distribute,

evenly distributes the objects, while Fixed distributes the objects

with a fixed distance (in points) between them.

Соседние файлы в папке Библиотеки Matlab