Index: ../trunk-jpl/src/m/solve/createxml.m =================================================================== --- ../trunk-jpl/src/m/solve/createxml.m (revision 0) +++ ../trunk-jpl/src/m/solve/createxml.m (revision 17721) @@ -0,0 +1,42 @@ +function createxml(xmlfilename,md) +%EXTRUDEXML - output an XML file compatible with inishell for automatic gui generation +% +% The routine creates an XML file that list fields from the underlying classes +% in model, and that can be use to render a GUI using the java code inishell +% +% Usage: +% createxml(md,xmlfilename) + +disp(['creating XML file ' xmlfilename]); + +%open file for binary writing +fid=fopen(xmlfilename,'w'); +if fid==-1, + error(['extrudexml error message: could not open ' xmlfilename,' file for ASCII writing']); +end + +%Go through all model fields: check that it is a class and call checkconsistency +fields=properties('model'); +fprintf(fid, '\n\n'); % require header for xml file +for i=1:length(fields), + field=fields{i}; + + %Some properties do not need to XML rendered + if ismember(field,{'results' 'radaroverlay' 'toolkits' 'private'}), + continue; + end + + %Check that current field is an object + if ~isobject(md.(field)) + error(['field ''' char(field) ''' is not an object']); + end + + %Create XML file for this subclass + createxml(md.(field),fid); +end +fprintf(fid, '\n\n'); % require footer for xml file +%close file +st=fclose(fid); +if st==-1, + error(['createxml error message: could not close file ' xmlfilename]); +end Index: ../trunk-jpl/src/m/solve/convert2str.m =================================================================== --- ../trunk-jpl/src/m/solve/convert2str.m (revision 0) +++ ../trunk-jpl/src/m/solve/convert2str.m (revision 17721) @@ -0,0 +1,130 @@ +function str = convert2str(field) + + str = parsedisplay(field); + +end %function + +function str = parsedisplay(field) % {{{ + + %string + if ischar(field), + + if length(field)>30; + %str = displayunit('not displayed'); + str=field; + else + str = displayunit(['''' field '''']); + end + + %cell + elseif iscell(field), + str = cell_display(field), + + %structure + elseif isstruct(field), + str = struct_display(field), + + %numeric + elseif isnumeric(field) + + %get size + fieldsize=size(field); + + %double + if max(fieldsize)==1, + str = displayunit(num2str(field)), + %matrix + else + str = displayunit(['(' num2str(fieldsize(1)) 'x' num2str(fieldsize(2)) ')']), + end + + %logical + elseif islogical(field) + + %get size + fieldsize=size(field); + + %single value + if max(fieldsize)==1, + if (field) + str = displayunit('true'); + else + str = displayunit('false'); + end + %matrix + else + str = displayunit(name,['(' num2str(fieldsize(1)) 'x' num2str(fieldsize(2)) ')']); + end + + %misc/ + else + str = displayunit(field); + + end + +end + +function str = displayunit(characterization)% {{{ + + %take care of characterization + if (strcmp(characterization,['''' '''']) || strcmp(characterization,'NaN')), + characterization='N/A'; + end + if length(characterization)>15, + characterization=[characterization(1:12) '...']; + end + + str = characterization; + +end% }}} + +function str = cell_display(field) + + %initialization + string='{'; + + %go through the cell and fill string + if length(field)<5; + for i=1:length(field), + if ischar(field{i}), + string=[string '''' field{i} ''',']; + elseif (isnumeric(field{i}) & length(field{i})==1) + string=[string num2str(field{i}) ',' ]; + else + string='{'; + break + end + end + end + if strcmp(string,'{'), + string=['(' num2str(size(field,1)) 'x' num2str(size(field,2)) ')']; + else + string=[string(1:end-1) '}']; + end + str = string; + + %disp(sprintf(string)); +end + +function str = struct_display(field) % {{{ + + if ~isempty(fields(field)) + displayunit('(structure)'), + + structure_fields=fields(field); + + for i=1:length(structure_fields), + + %get current field + sfield=field.(structure_fields{i}); + + %display value + %parsedisplay(sfield); + str = sfield; + end + + else + %displayunit('N/A'), + str = 'N/A'; + end +end% }}}