Contents     Functions              PDF Index

## comgui,cingui

Purpose

General utilities for graphical user interfaces.

Syntax

 comgui('Command', ...)
cingui('Command', ...)


comgui is an open source function that the user is expected to call directly while cingui is closed source and called internally by SDT.

### ImWrite, ...

ImwriteFileName.ext does a clean print of the current figure. The preferred strategy is to predefine options, so that comgui('ImWrite') alone defines options. This can be done by

comgui('ImWrite',gf,RO) with a figure handle given in gf and options stored in the RO structure, is the most general. gf can be omitted and will be taken to be gcf. RO can be omitted if options are given in the command. Acceptable options options are detailed below. For details for multi-image capture strategies (for example a set of modeshapes), see iicom ImWrite.

• FileName The default extension is .png. With no file name a dialog opens to select one. RO.FileName can be a cell array for a ImFtitle call.
• -NoCrop (or RO.NoCrop=1) avoids the default behavior where white spaces are eliminated around bitmap images.
• -FTitle (or RO.FTitle=1) uses the title/legend information to generate a file name starting with the provided filename.

A typical example would be comgui('imwrite-FTitle plots/root') which will generate a root_detail.png file in local directory plots.

For a given plot, comgui('imFTitle') can be used to check the target name.

• -LaTeX (or RO.LaTeX=1) displays LATEX commands to be used to include the figure in a file.
• -objSet"@Rep{SmallWide}" provides a tag to obtain predefined comgui objSet information to format the figure. Default formats available are
• SmallWide for a wide picture (9:16) (landscape style) adapted to reports.
• SmallSquare for a square picture (4:3) adapted to reports.
• SmallHigh for a vertical rectangular picture (9:16) adapted to reports.
• LargeWide for a wide picture (landscape style) adapted to posters.
• LargeSquare for a square picture (4:3) adapted to posters.
• WideBar for a (4:3) landscape style picture. It has the same width than SmallWide but is higher, this is mostly convenient for wide bar diagrams.
• -clipboard copies to clipboard.
• -SubToFig copies the display to another figure before reformatting (avoids modifying the current figure).
• -Java (or RO.Java=1) uses java to do a screen capture. RO.Java=2 captures the figure with the GUI, RO.Java=3 can be used to capture the dock containing the figure.
• -open (or RO.open=1) opens the figure in a browser.
• RO
• comgui('ImWrite ...',gf) ensures that the correct figure with pointer gf is captured.

### ImFtitle, ...

ImFtitle generates a file name for the figure based on current displayed content. Text is searched in objects with tags legend, ii_legend, in the axes title. By default all the text is concatenated and that can generate excessively long names so finer control is achieved by providing the name as a cell array in the ImWrite field of the userdata. The underlying mechanism to generate the string is described in comgui objString.

 figure(1);clf; t=linspace(0,2*pi);h=plot(t,[1:3]'*sin(t));
legend('a','b','c');title('MyTit');
% Define target plot directory in the figure
cingui('objset',1,{'@PlotWd',sdtdef('tempdir')})

% Check name generation, from string
comgui('imftitle',1,{'@PlotWd','@title','.png'})
% Do a direct call with name building
comgui('imwrite',struct('FileName',{{'@PlotWd','@title','.png'}}))

% Predefine the figure save name in the userdata.Imwrite of current axis
ua=v_handle('uo',gca); % Get handle to allow setting of .ImWrite field
ua.ImWrite={'@Plotwd','@title', ... % Search for plotwd, use title name
'@legend(1:2)','.png'}; % use first legend entry
% check image name, display clickable link for image generation
comgui('imftitle')

% Iiplot predefine strategy
%  - for curve : see sdtweb iiplot#PlotInfo
% Feplot predefine strategy
%  - for model : cf.ua.ImWrite as above
%  - during .Legend display see sdtweb comgui#def.Legend


### dock

SDT uses some docking utilities that are not supported by MATLAB. The actual implementation is thus likely to undergo changes.

 gf=1;figure(gf);clf; t=linspace(0,2*pi);h=plot(t,[1:3]'*sin(t));
comgui('objset',1,{'@dock','MAC'});  % Set in named dock group
% set the dock name and position
comgui('objset',1,{'@dock',{'name','MAC', ...
'arrangement',[1 3],'position',[0 0 300 200],...
'tileWidth',[.5 .25 .25]}});
% tileHeight also possible if arrangement(2)>1
pos=feval(iimouse('@getGroupPosition'),'MAC'); % get group position on screen
feval(iimouse('@deleteGroup'),'MAC') % Delete group (and figures)


Capture of a dock group figure is possible with comgui imwrite-Java3

### objSet

cingui('objSet',h,Prop) is the base SDT mechanism to generalize the MATLAB set command. It allows recursion into objects and on the fly replacement. Prop is a cell array of tag-value pairs classical in MATLAB handle properties with possible modifications. Three base mechanisms are object search, expansion and verification.

Object search '@tag',value applies value to an object to determined on the fly. For example '@xlabel' applies to the xlabel of the current axis.

• @xlabel accepts a value that is a cell array that will be propagated for all x labels. A typical example would be {'@xlabel',{'FontSize',12}}. Other accepted components are @ylabel, @zlabel, @title, @axes, @text,
• @axes, @figure will search for parent or child axes objects
• @tag is assumed to search for object with the given tag, so that its properties can be set. For example {'@ii_legend',{'FontSize',12}} will set the fontsize of an object with tag ii_legend.
• @tag(val) allows the selection of a specific object by index when multiple objects with the same tag are found.
• @ImFtitle is used to store the cell array for image name generation see comgui ImFtitle. This must be set after displaying title and legend entries, since the information is stored in these objects.
• @TickFcn allows a tick generation callback, see ii_plp TickFcn
• @dock handles docking operations, see comgui dock.
• @ToFig replicate the figure before applying operations. Property {'cf',val} can be used to force replication into figure val.

Expansion '','@tag' is first expanded by inserting a series of tag-value pairs resulting from the replacement of @tag. You can verify the expansion result using

cingui('fobjset','RepRef',{'','@Rep{SmallWide}'})

Replacement/verification

• position accepts NaN for reuse of current values. Thus [NaN NaN 300 100] only sets width and height.
• @def The value is a default stored in sdt_table_generation('Command'). One can search values by name within a cell array. This is in particular used for preset report formats @Rep{SmallWide} in comgui ImWrite.
• xlim, ... clim accept callbacks for the setting of limits. 'set(ga,”clim”,[-1 1]*max(abs(get(ga,”clim”))))' is a typical example setting symmetric color limits.
• '@setlines(”marker”)' or '@out=setlines(”marker”);' are two variants where the value is obtained as the result of a callback. Note that the variant with @out must end with a semicolumn. This is illustrated in the example below.
 figure(1);t=linspace(0,2*pi);h=plot(t,[1:3]'*sin(t));
cingui('objset',1, ...       % Handle to the object to modify
{'','@Rep{SmallWide}', ... % Predefined figure type
'@line','@setlines(''marker'')'}) % Line sequencing
cingui('fobjset','RepRef',{'','@Rep{SmallWide}'})


### objString

cingui('objString',h,SCell) is a mechanism to generate strings based on a set of properties. This is used by comgui ImFtitle but can also be used elsewhere.

 figure(1);clf;
t=linspace(0,2*pi);h=plot(t,[1:3]'*sin(t));title('MyTit')
legend('a','b','c');
SCell=   {'@Plotwd/plots', ... % Search for plotwd/plot
'@title', ... % use title name
'.png'}; % extension
cingui('objstring',1,SCell) % Handle of base object

• @PlotWd is the base mechanism to find the plotting directory. One seeks cf.def.PlotWd, cf.mdl.PlotWd, if they exist, then in objects with tag iicom_imwrite or PlotWd.

@PlotWd/relpath is accepted in name generation to allow simple generation of relative paths.

• @tag(1:2) allows selection of a subset of objects when multiple exist. Typical are @legend(1) to select the first string of a MATLAB legend, or @ii_legend(1) for an SDT ii_plp Legend entry. @headsub for the text used by feplot to display titles.
• @colorbar seeks the string associated with a colorbar

### def.Legend

The def.Legend field is used to control dynamic generation of text associated with a given display. It is stored using the classical form of property/value pairs stored in a cell array, whose access can be manual or more robustly done with sdsetprop.

Accepted properties any text property (see doc text) and the specific, case sensitive, properties

• set gives the initialization command in a string. This command if of the form 'legend -corner .01 .01 -reset' with
• cornerx y gives the position of the legend corner with respect to the current axis.
• -reset option deletes any legend existing in the current axis.
• string gives a cell array of string whose rows correspond to lines of the legend. $title is replaced by the string that would classically be displayed as label by feplot. Individual formatting of rows can be given as a cell array in the second column. For example {'\eta_1',{'interpreter','tex'}}. • ImWrite can be used to control file name generation (later used in automated multiple figure generation, see iicom ImWrite). The format in this case is a cell array giving the target directory followed by components used to build the string. Numbers then indicate rows of the legend text. You can also use '@tag' to force replacement with string of a text with the appropriate tag. In particular '@ColorbarTitle' lets you incorporate the colorbar string into your file name.  [model,def]=hexa8('testeig');cf=feplot(model); def.Legend={'set','legend -corner .1 .9 -reset', ... % Init 'string',{'$title';'\it MyCube'}, ... % The legend strings
'FontSize',12} % Other test properties
def=sdsetprop(def,'Legend','ImWrite',{ ...
'objSet','@Rep{SmallWide}', ... % Possible ImWrite options (optName)
sdtdef('tempdir'), ... % directory for writting file
'FigRoot', ... % root of figure name
'@ii_legend([2 1])', ... % insert second and first legend lines in file name
'.png'}) % Generate file as png
cf.def=def;
comgui('imFTitle') % Display the file name used comgui('imwrite')


### FitLabel

comgui('fitlabel') attempts to replace axes of the current figure so that xlabel, ylabel, ... are not cropped.