SDT-base         Contents     Functions         Previous Next     PDF Index

comgui,cingui

Purpose

General utilities for graphical user interfaces and figure formatting. Figure formatting documentation can be found in section 8.1.

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.

ImCrop

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.

ImWrite, ...

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. Not that you can also specify the figure to be printed using comgui('ImWrite',FigNum). Setting of options can be done by

The low level call 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.

It is also possible to directly capture a graphical java object which contains getVisibleRect and getLocationOnScreen properties. Simply provide the java object as instead of a figure handle.

sdtweb sdt % Open sdt.html in the help browser
pause(2); % Wait for the display
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
r1=desktop.getGroupContainer('Help') % Get the java container of the help browser
% Save the HelpBrowser capture in the tempdir with name testjavacapture.png
comgui('imwrite testjavacapture',r1); 

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 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

ImInfo

Command comgui('iminfo',gf) shows the structure containing all the figure formatting options for figure gf (see command PlotWd)

dock

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],...
   'dockgroup',false, ...   % Do not dock the dock into the MATLAB desktop
   '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

guifeplot,iiplot

 cf=comgui('guifeplot -reset -project "SDT Root"',2);
 comgui('iminfo',cf) % View what was set

Is used to force a clean open of an feplot figure. The option -reset is used to force emptying of the figure. The option -project is used to combine a call to comgui PlotWd to define the project.

Formatting styles sdtroot OsDic are also stored in the project.

objSet (handle formatting)

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

% Define OsDic entries in project
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')})
% Example of apply call
figure(1);plot(sin(linspace(0,4*pi)'*[1:3]))
cingui('objset',1,{'@OsDic(SDT Root)',{'feplotA','grid','LiMarker'}})
% Get OsDic data for given entry
sdtroot('cbosdicget',[],'ImLW75') % in project
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}'})

objString (string generation for title and file)

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

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

ParamEdit

cingui('ParamEdit') calls are used to clarify filling of options data structures as detailed in section 7.17.4.

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

 [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;

PlotWd

A key aspect of image generation is to define meta-data associated with a figure. These include, directory where the image will be saved, file name, possible inclusion in Word, PowerPoint, ... The Project tab defines the plot directory and possibly a file for inclusion. Other properties are set using the PlotWd command cingui('plotwd',gf,'@OsDic(SDT Root)',list) as illustrated below.

The list is a cell array of object set dictionary (OsDic) entries. To analyze reference implementation of OsDic, see sdtweb('_taglist','d_imw').

t=linspace(0,pi); % basic plot
gf=1;figure(gf);clf;plot(t,sin(t));
title('TestFigure');legend('a');
% Define the project directory
sdtroot('SetProject',struct('PlotWd',sdtdef('tempdir')))
if ispc; sdtroot('SetProject',struct('Report','sdt.docx'))
else; sdtroot('SetProject',struct('Report','sdt.pptx'))
end
help d_imw % see common calls
% Prepare for image generation.
list={ ...  % List of OsDic entries, implemented in d_imw
  'Reset', ...    % Remove preexisting information
  'ImToFigN', ... % Duplicate to new figure before ImWrite
  'FnTitle', ...  % Generate file name based on Title
  'WrW49C'        % Insert in word with 49% wide centered
  };
% Associate figure gf with project SDT Root
cingui('plotwd',gf,'@OsDic(SDT Root)',list) 
comgui('iminfo',gf) % View what was set
comgui('imwrite',gf) % Actually insert image

When initializing in a feplot figure, use cf=comgui('guifeplot -project "SDT Root"',2) to set the project information. Similarly use cf=comgui('guiiiplot -project "SDT Root"',2) to set the project information of iiplot figures.

When refining formatting beyond specifying directory, insertion file, accepted property/value pairs (a structure can also be used but this is not the norm)

FitLabel

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


©1991-2024 by SDTools
Previous Up Next