Contents   Functions      PDF Index |
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.
Image cropping utilities. This function allows cropping uniform borders and uniform rows or columns in an image.
Syntax is a=comgui('ImCrop',a)'
Image a can be either
The following command options are available
You can include cropping options within an ImWrite call by defining a .CropOpt field in the option structure.
ImwriteFileName.ext does a clean print of the current figure. The preferred strategy is to predefine options, so that comgui('ImWrite') alone is sufficient to generate a figure. 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 as strings in the command. Thus ImWrite-NoCrop is the same as using RO.NoCrop=1.
For details for multi-image capture strategies (for example a set of modeshapes), see iicom ImWrite.
Acceptable options are detailed below.
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.
Using a cell .FileName calls comgui ImFtitle to let you build the file name from elements within the figure.
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 FileName as a cell array in the comgui PlotWd call. 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 comgui('PlotWd',1,'FileName', ... {'@Plotwd','@title', ... % Search for plotwd, use title name '@legend(1:2)','.png'}); % use first legend entry comgui('imInfo') % See parameters % check image name, display clickable link for image generation comgui('imftitle') sdtweb('_link','comgui(''Imwrite'')','Generate'); d_imw('Fn') % Standard names styles for tile name generation
SDT uses some docking utilities that are not supported by MATLAB. The actual implementation is thus likely to undergo changes.
gf=11;figure(gf);clf; t=linspace(0,2*pi);h=plot(t,[1:3]'*sin(t)); figure(12);plot(rand(3));figure(13);mesh(peaks); % set the dock name and position comgui('objset',[11 12 13],{'@dock',{'name','MAC', ... 'arrangement',[1 1 2;1 1 3], ... % Automated tile merging 'position',[0 0 600 400],... 'tileWidth',[.4 .6], ... % Fraction of columns 'tileHeight',[.3 .7]}}); % Fraction of rows pos=feval(iimouse('@getGroupPosition'),'MAC'); % group screen position figure(14); % Add a new figure in specified tile cingui('objset',14,{'@Dock',{'Name','MAC','Tile',11}}); feval(iimouse('@deleteGroup'),'MAC') % Delete group (and figures)
Capture of a dock group figure is possible with comgui imwrite-Java3
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 property/values pairs stored in value to an object to determined on the fly. For example '@xlabel' applies to the xlabel of the current axis.
Expansion modifies the current property/value list by replacing a given entry.
The two uses are illustrated below
sdtroot('SetOsDic',{'feplotA',{'Position',[NaN NaN 500 300]}; 'font12',{'@axes',{'fontsize',12},'@title',{'fontsize',12}} 'grid',{'@axes',{'xgrid','on','ygrid','on','zgrid','on'}} }); sdtroot('setOsDic', ... % Define a line sequence {'LiMarker',setlines(jet(5),{'-','--','-.'},'+ox*sdv^><ph')}) figure(1);plot(sin(linspace(0,4*pi)'*[1:3])) cingui('objset',1,{'@OsDic(SDT Root)',{'feplotA','grid','LiMarker'}}) cingui('fobjset','RepRef',{'@OsDic',{'feplotA','grid'}}) cingui('fobjset','RepRef',{'','@Rep{SmallWide}'})
Value replacement/verification performs checks/callbacks to determine the actual value to be used in the MATLAB set.
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}'})
cingui('objString',h,SCell) is a mechanism to generate strings based on a set of properties. Elements of SCell are replaced when starting by an @, with implemented methods being
@PlotWd/relpath is accepted in name generation to allow simple generation of relative paths.
This is used by comgui ImFtitle to generate figure names, but can also be used elsewhere (fe_range, ...). For example in title generation.
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
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
[model,def]=hexa8('testeig');cf=feplot(model); cf.data.root='\it MyCube'; def.Legend={'set','legend -corner .1 .9 -reset', ... % Init 'string',{'$title';'@cf.data.root'}, ... % The legend strings 'FontSize',12} % Other test properties cf.def=def;
Determination of the target directory for plotting is a key aspect of image generation.
Accepted fields of the PlotWd structure are
When initializing in a feplot figure, cf.def.PlotWd, cf.mdl.PlotWd are used first if they exist. Objects with tag iicom_imwrite or PlotWd are used next (and generated by objSet commands if they do not exist).
t=linspace(0,pi); % basic plot gf=1;figure(gf);clf;plot(t,sin(t)); title('TestFigure');legend('a'); % Define the target directory sdtroot('SetProject',struct('PlotWd',sdtdef('tempdir'))) % Prepare for image generation. list={ ... % List of OsDic entries, implemented in d_imw 'ImToFigN', ... % Duplicate to new figure before ImWrite 'FnTitle', ... % Generate file name based on Title 'WrW49C' % Insert in word with 49% wide centered }; cingui('plotwd',gf,'@OsDic(SDT Root)',list) comgui('iminfo',gf) % View what was set comgui('imwrite',gf) % Actually insert image
Capture of a dock group figure is possible with comgui imwrite-Java3
comgui('fitlabel') attempts to replace axes of the current figure so that xlabel, ylabel, ... are not cropped.