Mercurial > hg > ltpda
comparison m-toolbox/classes/@history/dotview.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % DOTVIEW view history of an object via the DOT interpreter. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: DOTVIEW view history of an object via the DOT interpreter. | |
5 % | |
6 % The history is converted to a dot file (www.graphviz.org) then: | |
7 % 1) rendered to the format specified inside the user's LTPDA Toolbox Preferences | |
8 % (accessible via the dedicated GUI or typing "LTPDAprefs" on the Matlb terminal) | |
9 % 2) opened with the chosen viewer. | |
10 % 3) The graphic file is kept. | |
11 % | |
12 % CALL: dotview(h, pl); | |
13 % dotview(h, 'my_filename'); | |
14 % dotview(h); % Displays only the diagram | |
15 % | |
16 % INPUTS: h - history object | |
17 % pl - plist of options | |
18 % | |
19 % | |
20 % VERSION: $Id: dotview.m,v 1.17 2010/09/17 14:08:51 ingo Exp $ | |
21 % | |
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
23 | |
24 function varargout = dotview(varargin) | |
25 | |
26 % get global variables | |
27 prefs = getappdata(0, 'LTPDApreferences'); | |
28 DOT = char(prefs.getExternalPrefs.getDotBinaryPath); | |
29 FEXT = char(prefs.getExternalPrefs.getDotOutputFormat); | |
30 | |
31 %%% Set inputs | |
32 objs = utils.helper.collect_objects(varargin(:), 'history'); | |
33 pl = utils.helper.collect_objects(varargin(:), 'plist'); | |
34 fn = utils.helper.collect_objects(varargin(:), 'char'); | |
35 | |
36 pl = combine(pl, getDefaultPlist); | |
37 | |
38 view = find(pl, 'view'); | |
39 iformat = find(pl, 'format'); | |
40 if ~isempty(fn) | |
41 filename = fn; | |
42 else | |
43 filename = find(pl, 'filename'); | |
44 end | |
45 | |
46 % Create tempoary filename | |
47 if isempty(filename) | |
48 filename = fullfile(tempdir, 'ltpda_dotview.pdf'); | |
49 end | |
50 if ~isempty(iformat) | |
51 FEXT = iformat; | |
52 end | |
53 | |
54 for jj=1:numel(objs) | |
55 | |
56 [path, name, ext] = fileparts(filename); | |
57 | |
58 % Convert ssm to a tmp dot file | |
59 tname = tempname; | |
60 dotfile = [tname '.dot']; | |
61 outfile = fullfile(path, [name '.' FEXT]); | |
62 | |
63 % Make DOT file | |
64 hist2dot(objs(jj), dotfile, pl); | |
65 | |
66 % Write to graphics file | |
67 cmd = sprintf('%s -T%s -o %s %s', DOT, FEXT, outfile, dotfile); | |
68 system(cmd); | |
69 | |
70 % View graphics file | |
71 if view | |
72 if any(strcmpi(FEXT, {'gif', 'ico', 'jpg', 'jpeg', 'jpe', 'png', 'tiff'})) | |
73 image(imread(outfile)); | |
74 else | |
75 open(outfile); | |
76 end | |
77 end | |
78 | |
79 % Delete tmp dotfile | |
80 delete(dotfile); | |
81 end | |
82 | |
83 end | |
84 | |
85 | |
86 %-------------------------------------------------------------------------- | |
87 % Get Default Plist | |
88 %-------------------------------------------------------------------------- | |
89 function plo = getDefaultPlist() | |
90 | |
91 % Use the "factory" plist | |
92 plo = plist.DOTVIEW_PLIST; | |
93 | |
94 end | |
95 |