sdtroot, sdt_locale#
Purpose
Base SDT GUI figure handling.
Description
This function is used to implement base SDT mechanisms for tabs shown in JAVA GUI. It also supports advanced structure manipulations (stored here due to interactions with structure like objects aka handles and other SDT objects)
Init#
Commands for tab initialization/refreshing. InitPTree is an example of initialization of the navigation pane. InitProject implements the typical project tab which is detailed in section 8.1.2. InitPref opens the SDT preference editor.
Set#
Commands for property setting. Implements SetPref for preferences, SetProject for generic project parameters and and generic setting of fields defined in PARAM.
The default mechanism for set is to specify the tab in the command and provide data to be set a structure where each field describes a cell in the tab. An example for the Project tab.
tdir=sdtdef('tempdir'); sdtroot('SetProject',struct('ProjectWd',tdir, ... % Root file location 'PlotWd',fullfile(tdir,'plots'), ... % Plot directory 'Report',fullfile(tdir,'tmp_word.docx'))); % Word file for image insert
PARAM#
PARAM commands are used to retrieve data stored normally stored in the userdata of the project figure.
- PA=sdtroot('paramVH') gives a v_handle to the main project data structure.
- RO=sdtroot('PARAM2RO') resolves all java dependencies and returns a basic MATLAB struct containing all parameters.
- To access individual data prefer calls with field names. The -safe option performs inits if needed.
st=sdtroot('PARAM.Project.ProjectWd -safe') r1=sdtroot('PARAM.Project')
- sdtroot('PARAMWord') initializes for potential export based on content of PlotWd and PlotWord
OsDic#
Each project figure supports a dictionary (or OsDic) of named comgui objSet styles that can be used to format figures, images, ... The following illustrates simple manipulations, for a list of usual categories see section 8.1.
% Sample style definition, see examples in d_imw my_style={'position',[NaN,NaN,1087,384],'@line',{'linewidth',5}}; sdtroot('InitOsDic'); % Display list of named styles sdtroot('setOsDic',{'ImMyStyle',my_style}) % Associate ImMyStyle name to this style figure(1);plot([0 1]); comgui('objset',1,{'@OsDic(SDT Root)','ImMyStyle'}); % Apply named style
@sfield#
Subcommand sfield provides structure manipulation utilities. It can be accessed by calling sfield=sdtroot('@sfield');.
The following commands are available
-
AddMissing Completes a structure with fields found missing from a default structure. r1=sfield('AddMissing',r1,r2). Inputs r1 is the working structure, r2 is a default structure. Output r1 is the input structure for which fields of r2 that were not present have been added. Field names are case sensitive.
r1=struct('PostCheck',1,'Opt','test','PostName','NameP','run',true); r2=struct('Opt','ttt','other','value'); r1=feval(sdtroot('@sfield'),'AddMissing',r1,r2);
- AddSelected Completes a structure with fields found missing from a default structure, for a given list of field names to intersect. r1=sfield('AddSelected',r1,r2,list);. Inputs r1 is the working structure, r2 is a default structure, list is a list of field names to consider. Output r1 is the input structure for which fields of r2 that were not present and intersected in list have been added. Field names are case sensitive.
r1=struct('PostCheck',1,'Opt','test','PostName','NameP','run',true); r2=struct('Opt','ttt','other','value','field',true); r1=feval(sdtroot('@sfield'),'AddSelected',r1,r2,{'field'});
- AddIncF Adds to a main structure the fields from another structure, fields names in the second structure that are already present are incremented with a number added to the field name end. r1=sfield('AddIncF',r1,r2).
r1=struct('PostCheck',1,'Opt','test','PostName','NameP','run',true); r2=struct('Opt','ttt'); r1=feval(sdtroot('@sfield'),'AddIncF',r1,r2);
- Cell2Struct Robust transform of a cell array in format {tag,data,...}, or {tag,data; ...} to a structure. r1=sfield('Cell2Struct',list);.
list={'tag',{'value','test'},'opt',1}; r1=feval(sdtroot('@sfield'),'Cell2Struct',list);
- GetField Case insensitive field recovery. val=sfield('GetField',r1,field,typ); r1 is an input structure, field is the field name to recover, typ is the output wanted, if set to 'name' the fieldname is output, the associated value is provided otherwise.
r1=struct('PostCheck',1,'Opt','test','PostName','NameP','run',true); v1=feval(sdtroot('@sfield'),'GetField',r1,'postname','field'); f1=feval(sdtroot('@sfield'),'GetField',r1,'postname','name');
- MergeI Merge two structures into a single one with case insensitive field name union. r1=sfield('MergeI',r1,r2);. Output r1 is a structure with merged fields of inputs r1 and r2 with priority given on r1.
r1=struct('PostCheck',1,'Opt','test','PostName','NameP','run',true); r2=struct('opt','ttt','other','value'); r1=feval(sdtroot('@sfield'),'MergeI',r1,r2);
- Sub Recovers fields from a structures whose names match a given pattern (through a regular expression). r2=sfield('Sub',r1,pat,typ):. Output r2 is a structure whose fields are fields from input structure r1 that were matched with pat as a regular expression. If typ is set to true, the matched pattern is removed from the output field name, kept otherwise.
r1=struct('PostCheck',1,'Opt','test','PostName','NameP','run',true); r2=feval(sdtroot('@sfield'),'Sub',r1,'^Post',1);