0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function ltpdagui(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % =========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % LTPDA GUI
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % =========================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % Open the main LTPDA GUI.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % $Id: ltpdagui.m,v 1.27 2009/01/23 12:40:51 nicola Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 warning off all
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 global LTPDAinvar LTPDAoutvar active labels scaleX
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 tabbedFigName = 'Family GUI';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 screenSize = get(0,'screensize');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 scaleX = screenSize(3)/1280;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 if scaleX<1, scaleX = 1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 setappdata(0, 'ltpda_gui_scalefactor',scaleX);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 guiSize = [1 1 600*scaleX 550*scaleX];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 guiSize = round([(screenSize(3)-guiSize(3))/2 , (screenSize(4)-guiSize(4))/2 , guiSize(3) , guiSize(4)]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 if ~isempty(findobj('Tag','LTPDAGUI')) && nargin==0, return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 if isempty(LTPDAinvar), LTPDAinvar = {}; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 if isempty(LTPDAoutvar), LTPDAoutvar = {}; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 userID = getappdata(0,'ltpda_repo_user');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 if isempty(userID), userID = ''; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 passwd = getappdata(0,'ltpda_repo_pass');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 if isempty(passwd), passwd = ''; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 if nargin==0, setappdata(0,'startup',1); [userID passwd] = utils.mysql.logindlg(userID,'',1,tabbedFigName,guiSize); try cd(getappdata(0,'DefaultDataDirectory')); catch, end; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 if isempty(userID), userID = 'JohnDoe'; passwd=''; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 setappdata(0,'ltpda_repo_user',userID)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 setappdata(0,'ltpda_repo_pass',passwd)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 if nargin==0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 clc
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 disp('Please wait: starting LTPDA GUI...')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 disp('Loading Simulink...')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 drawnow
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 load_system('simulink')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 load_system('ltpda_library')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 try stop(timerfindall); delete(timerfindall); catch end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 t1 = timer('TimerFcn',@CheckTimerAlive,'ExecutionMode','fixedRate','Period',0.3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 t2 = timer('TimerFcn',@CheckTimerAlive,'ExecutionMode','fixedRate','Period',1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 start(t1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 start(t2)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 tag = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 units = 'normalized';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 position = [0,0,1,1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 % text color in the label:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 foregroundcolor = [0.2,0.2,0.2];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % color in the background, behind tabs:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 backgroundcolor = [0.7,0.7,1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 % background color, inside every tab:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 panelbackgroundcolor = [0.98,0.98,0.98];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 % color of the small highlight line, above the selected tab
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 titlehighlightcolor = [1,0.3,0];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 horizontalalignment = 'center';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 active = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 string = {'Main LTPDA panel','Parameters','Output','';'Repository','Partial execution','Nested loops','Globals'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 nrows = size(string,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 if nrows>1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 for nn=1:nrows, labels{nn} = string(nn,:); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 string = string(1,:);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 ntab = numel(string);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 for jj=ntab:-1:1, ntab = ntab - strcmp(string(jj),''); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 % Cycle to retrieve parameters from the user:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 for mm=1:2:nargin
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 property = lower(varargin{mm});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 value = varargin{mm+1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 switch property
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 case {'title','string'}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 string = value;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 nrows = size(string,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 if nrows>1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 for nn=1:nrows, labels{nn} = string(nn,:);end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 string = string(1,:);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 ntab = numel(string);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 for jj=ntab:-1:1, ntab = ntab - strcmp(string(jj),''); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 case {'frameposition','position'}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 position = value;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 case {'framebackgroundcolor','backgroundcolor'}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 backgroundcolor = value;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 case {'framebordertype','bordertype'}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 bordertype = value;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 case {'titleforegroundcolor','foregroundcolor'}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 foregroundcolor = value;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 case {'selecteditem','active'}
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 active = value;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 case 'redraw'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 if value == 1 % main panel
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 TopBottomTabCbk([],[],1,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 active = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 if value == 1.1 % the user clicked the Start button
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 TopBottomTabCbk([],[],1,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 active = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 runSim = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 if value == 2 % Parameters panel
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 TopBottomTabCbk([],[],2,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 active = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 if value == 6 % globals panel
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 TopBottomTabCbk([],[],4,2)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 active = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 if value == 8 % nested loops
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 TopBottomTabCbk([],[],3,2)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 active = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 case 'callback'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 if value==1 && strcmp(bdroot,'ltpda_library')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 HelpCallback();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 return;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 if value==1 && isempty(findobj('Name',tabbedFigName))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 return;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 eval([property '= ' value ';']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 parent = findobj('Tag','LTPDAGUI');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 if ~isempty(parent), clf(parent); set(parent,'Resize','on','ResizeFcn',{@GUIResize,guiSize});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 else parent = figure('Position',guiSize,'Name',tabbedFigName,'Resize','on','ResizeFcn',{@GUIResize,guiSize},'NumberTitle','off','Toolbar','none','Menubar','none');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 set(parent,'Tag','LTPDAGUI','NextPlot','new');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 if ~exist('margins','var'), margins = {1,'pixels'}; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 if ~iscell(margins), margins = {margins,units}; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 if ~exist('bordertype','var'), bordertype = 'none'; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 if ~exist('titlebackgroundcolor','var'), titlebackgroundcolor = 0.95*panelbackgroundcolor; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 if ~active, active = 1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 clear htab
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 htab = uipanel( ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 'Parent',parent, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 'Units',units, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 'Position',position, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 'BackgroundColor',backgroundcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 'BorderType',bordertype, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 'Visible','on', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 'Tag',tag);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 set(htab,'Units','pixels');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 tabpos = get(htab,'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 status = uicontainer( ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 'Parent',htab, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 'BackgroundColor',backgroundcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 'Units',margins{2}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 'Position',[1,1,1,1], ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 'Visible','off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 set(status,'Units','pixels');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 charsz = get(status,'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 margins = [charsz(1:2),charsz(1:2)].*margins{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 set(status,'Units','characters');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 set(status,'Position',[1,1,1,1]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 set(status,'Units','pixels');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 charsz = get(status,'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 titleheight = 2.4*charsz(4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 titleheight = titleheight*scaleX;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 margins(3:4) = -(margins(1:2)+margins(3:4));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 [loop,sign] = deal(1:ntab,[1,ntab,1,0]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 addtitle = 2*[sign(3:4),-1,-1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 ttextpos = [0.05,0.08,0.9,0.76];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 for kk=1:ntab
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 title(kk) = uipanel( ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 'Parent',htab, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 'Units','pixels', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 'BackgroundColor',titlebackgroundcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 'BorderType','beveledout', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 'ButtonDownFcn',{@TopBottomTabCbk,kk,1}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 'Visible','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 ttext(kk) = uicontrol( ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 'Parent',title(kk), ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 'Units','normalized', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 'Position',ttextpos, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 'ForegroundColor',foregroundcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 'BackgroundColor',titlebackgroundcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 'HorizontalAlignment',horizontalalignment, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 'Style','text', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 'String',string{kk}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 'FontSize',11*scaleX,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 'Enable','inactive', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 'HitTest','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 'Visible','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 set(htab,'Units','pixels');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 dimension = get(htab,'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 dimension(4) = dimension(4)-nrows*titleheight+5;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 panel = uipanel('Parent',htab,'Tag','mainPanel','Units','pixels','Position',dimension,'BackgroundColor',panelbackgroundcolor,'BorderType','beveledout','Visible','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 dimension = get(htab,'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 logosize = [52,52];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 dimension = [dimension(3)-logosize(1)-3 , dimension(4)-logosize(2) , logosize];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 logo = axes('Parent',htab,'Units','pixels','Position',dimension,'Tag','Logo');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 image(imread('iconltp.jpg'),'Parent',logo,'AlphaData',imread('iconltpalpha.gif'),'ButtonDownFcn','try open_system(gcs); catch, end;');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 axis(logo,'off'); axis(logo,'square');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 set(logo,'HandleVisibility','callback');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 dimension = get(htab,'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 logosize = [40 40];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 dimension = [dimension(3)-logosize(1)-70 , dimension(4)-logosize(2)-9 , logosize];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 start2 = axes('Parent',htab,'Units','pixels','Position',dimension,'Tag','Start2');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 image(imread('startgreen.jpg'),'Parent',start2,'AlphaData',imread('startalpha.gif'),'ButtonDownFcn','ltpdagui(''redraw'',1.1);','Tag','StartButton');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 axis(start2,'off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 set(start2,'HandleVisibility','callback');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 if active>ntab, active=ntab; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 inset(1) = uicontrol( ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 'Parent',htab, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 'Units','pixels', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 'BackgroundColor',panelbackgroundcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 'Style','text', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 'Visible','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 if ~isnan(titlehighlightcolor)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 inset(2) = uicontrol( ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 'Parent',htab, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 'Units','pixels', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 'BackgroundColor',titlehighlightcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 'Style','text', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 'Visible','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 inset(3) = uicontrol( ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 'Parent',htab, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 'Units','pixels', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 'BackgroundColor',0.85*titlehighlightcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 'Style','text', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 'Visible','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 % OTHER BUTTONS
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 for xx=2:nrows
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 localString = labels{xx};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 ntab = numel(localString);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 for tt=1:ntab
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 titles(xx,tt) = uipanel( ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 'Parent',htab, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 'Units','pixels', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 'BackgroundColor',titlebackgroundcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 'BorderType','beveledout', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 'ButtonDownFcn',{@TopBottomTabCbk,tt,xx}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 'Visible','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 uicontrol( ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 'Parent',titles(xx,tt), ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 'Units','normalized', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 'Position',ttextpos, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 'ForegroundColor',foregroundcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 'BackgroundColor',titlebackgroundcolor, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 'HorizontalAlignment',horizontalalignment, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 'Style','text', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 'String',localString{tt}, ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 'Enable','inactive', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 'FontSize',11*scaleX,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 'HitTest','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 'Visible','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 TopBottomTabResizeCbk();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 panelTitle = get(ttext(active),'string');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 setappdata(0, 'ltpda_currPanel', panel);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 CheckTimerAlive()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 switch panelTitle
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 case 'Main LTPDA panel'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 if exist('runSim','var') && runSim==1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 runSim = 0; %#ok<NASGU>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 pan1main(panel,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 else pan1main(panel)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 case 'Parameters'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 pan2param(panel)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 case 'Repository'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 pan3repo(panel)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 case 'Import from workspace'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 pan4import(panel)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 case 'Output'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 pan5output(panel)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 case 'Globals'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 pan6globals(panel)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 case 'Partial execution'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 pan7partial(panel)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 case 'Nested loops'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 % panXyettocome(panel)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 pan8nested(panel)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 function TopBottomTabCbk(hobj,evdt,indx,numbrow) %#ok<INUSL>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 % Executed when the user clicks on a another tab or resize.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 if numbrow>1 % the user clicked on another row
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 for pp=ntab:-1:1, ntab = ntab - strcmp(string(pp),''); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 if ntab==1, active=1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 % Swop rows:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 temp = labels(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 labels(1) = labels(numbrow);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 labels(numbrow) = temp;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 clear temp
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 % Rebuild the proper list:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 for ii=1:nrows
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 temp(ii,1:numel(labels{ii}))=labels{ii};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 active = indx;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 for ii=1:nrows
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 temp(ii,1:numel(labels{ii}))=labels{ii};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 % ======================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 ltpdagui('title',temp,'active',indx);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 % ======================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 function TopBottomTabResizeCbk(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 % Properly draws the panels.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 units = get(htab,'Units');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 set(htab,'Units','pixels');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 tabpos = get(htab,'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 tabpos(3) = tabpos(3)-120;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 set(htab,'Units',units);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 ntab = numel(string);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 for oo=ntab:-1:1, ntab = ntab - strcmp(string(oo),''); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 titlepos = [0,0,0,titleheight];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381 panelpos = [0,0,tabpos(3),tabpos(4)-titleheight]+margins;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 titlepos(2) = panelpos(2)+panelpos(4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 panelpos(2) = panelpos(2)-titleheight*(nrows-1)+6;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 n = sum(cellfun('length',string))+2*ntab;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 titlepos(1) = panelpos(1)+(1-sign(3))*panelpos(3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 upperpos = titlepos(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 for k=loop
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389 titlepos(3) = panelpos(3)*(length(string{k})+2)/n;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 addtopos = addtitle.*[k==1,1,k==1|k==ntab,1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 titlepos(1) = titlepos(1)-(1-sign(3))*titlepos(3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 titlepos(2) = upperpos - titlepos(4)*(nrows-1)+3+1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 set(title(k),'Position',titlepos+addtopos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394 titlepos(1) = titlepos(1)+sign(3)*titlepos(3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 if nrows>1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 for xxx=2:nrows
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 localString = labels{xxx};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 ntab = numel(localString);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 for i=ntab:-1:1, ntab = ntab - strcmp(localString(i),''); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 n = sum(cellfun('length',localString))+2*ntab;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 titlepos(1) = panelpos(1)+(1-sign(3))*panelpos(3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 titlepos(2) = titlepos(2) + titlepos(4)-2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 for k=1:ntab
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408 titlepos(3) = panelpos(3)*(length(localString{k})+2)/n;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 addtopos = addtitle.*[k==1,1,k==1|k==ntab,1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 titlepos(1) = titlepos(1)-(1-sign(3))*titlepos(3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 if ntab==1, titlepos(3)=titlepos(3)-2; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 set(titles(xxx,k),'Position',titlepos+addtopos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 titlepos(1) = titlepos(1)+sign(3)*titlepos(3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 if ntab<numel(localString)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 for qq=ntab+1:numel(localString)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 nullpos=[0,0,1,1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 set(titles(xxx,qq),'Position',nullpos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 % =======================================================================
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 titlepos = get(title(active),'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 titlepos = titlepos-addtitle.*[active==sign(1),1,active==sign(1),1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 titlepos(3) = titlepos(3)-addtitle(3)*(active==sign(2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 ntab = numel(string);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 for i=ntab:-1:1, ntab = ntab - strcmp(string(i),''); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 if ntab==1, titlepos(3) = titlepos(3)-4; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 set(title(active),'Position',titlepos,'BackgroundColor',panelbackgroundcolor);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 set(ttext(active),'FontWeight','bold','BackgroundColor',panelbackgroundcolor);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 insetpos = [titlepos(1)+1,titlepos(2)+sign(4)*titlepos(4)-2,titlepos(3)-1,3];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 set(inset(1),'Position',insetpos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 insetpos = insetpos+[0,(1-2*sign(4))*titleheight+2*sign(4),0,-2];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 set(inset(2),'Position',insetpos);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 set(inset(3),'Position',insetpos+[2,1-2*sign(4),-4,0]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 function GUIResize(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 % Called whenever the user resize the GUI window.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 guiSize = varargin{3};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 newSize = get(findobj('Tag','LTPDAGUI'),'Position');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 % To avoid a width lower than the fixed minimum:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 if newSize(3)<guiSize(3), newSize(3)=guiSize(3); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456 % To avoid an height lower than the fixed minimum:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 if newSize(4)<guiSize(4), newSize(4)=guiSize(4); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 % To avoid a window moved outside the screen border:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 screenSize = get(0,'screensize');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 if newSize(2)+newSize(4)+30>screenSize(4), newSize(2)=screenSize(4)-newSize(4)-40; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 if newSize(1)+newSize(3)>screenSize(3), newSize(1)=screenSize(3)-newSize(3)-5; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 set(findobj('Tag','LTPDAGUI'),'Position',newSize);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465 % Redraw the GUI on the current panel:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 % pause(0.1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 if ~getappdata(0,'startup'), TopBottomTabCbk([],[],active,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 else setappdata(0,'startup',0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 %%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 function CheckTimerAlive(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477 % This is the function to execute a continuous timer check
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 % Keep alive the first timer:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 alltimers = timerfindall;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 if strcmp(get(alltimers(1),'Running'),'off'), start(alltimers(1)); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 function HelpCallback(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 % Whenever the user doubleclick a block in the library window (ie, the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488 % OpenFcn callback is executed from the library).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 openSys = find_system('SearchDepth',0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 for ii=1:numel(openSys)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 if ~isempty(find_system(openSys{ii},'FindAll','on','Type','Annotation','Tag','ltpda model'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 add_block(gcb,[openSys{ii},'/',get_param(gcb,'Name')],'MakeNameUnique','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 return;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498 childpath = find_system(gcbh,'LookUnderMasks','all','BlockType','M-S-Function');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499 functionname = get_param(childpath,'Tag');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 description = get_param(gcbh,'Description');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 funcname = findstr('functionName=',description);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 if funcname
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 i = funcname+14;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 while ~strcmp(description(i),';'), i=i+1; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506 functionname = description(funcname+14:i-2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 [func,classes] = strtok(get(gcbh,'Tag'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 if strcmp(func,'method')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 helptext = help([strtrim(classes),'/',functionname]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 helptext = help(functionname);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 helpFigure = figure('MenuBar','none','Toolbar','none','Name',strcat(functionname,' help'),'NumberTitle','off','Units','pixels','Position',[200,200,500,300],'Resize','on','ResizeFcn','refresh(gcf)','Tag','helpwindow','Color', get(0, 'defaultuicontrolbackgroundcolor'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517 % Help text:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518 uicontrol('Parent',helpFigure,'Units','normalized','HorizontalAlignment','left','Position',[0 0 1 1],'FontSize',8,'String',helptext,'Visible','on','max',100,'Style','edit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522 %----------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524 end |