-
Notifications
You must be signed in to change notification settings - Fork 98
/
ea_busyaction.m
194 lines (177 loc) · 7.29 KB
/
ea_busyaction.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
function ea_busyaction(varargin)
% function displays or hides a spinning wheel on top right corner (default)
% of figure.
if isa(varargin{2}, 'matlab.ui.control.Image')
switch varargin{1}
case 'on'
varargin{2}.Visible = 'on';
varargin{2}.ImageSource = fullfile(ea_getearoot, 'icons', 'busy.gif');
varargin{2}.Tooltip = 'Busy';
case 'off'
varargin{2}.ImageSource = fullfile(ea_getearoot, 'icons', 'idle.png');
varargin{2}.Tooltip = 'Idle';
end
drawnow;
return;
end
try
onoff=varargin{1};
fighandle=varargin{2};
if nargin>2
pos=varargin{3};
else
sz=get(fighandle,'Position');
pos=[sz(3)-80-10 sz(4)-10-80 50 50];
end
if ischar(pos)
switch pos
case 'dbs'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Lead DBS (busy...)';
offfigtit='Lead DBS';
case 'coreg'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-42-2 50 50];
onfigtit='Check Coregistration (busy...)';
offfigtit='Check Coregistration';
case 'atlcontrol'
sz=get(fighandle,'Position');
pos=[sz(3)-50+4 sz(4)-50+8 50 50];
onfigtit='Atlas Control (busy...)';
offfigtit='Atlas Control';
case 'anatomy'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Lead Anatomy (busy...)';
offfigtit='Lead Anatomy';
case 'mapper'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Lead Connectome Mapper (busy...)';
offfigtit='Lead Connectome Mapper';
case 'connectome'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Lead Connectome (busy...)';
offfigtit='Lead Connectome';
case 'predict'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Lead Predict (busy...)';
offfigtit='Lead Predict';
case 'or'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Lead OR (busy...)';
offfigtit='Lead OR';
case 'acpc'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='ACPC/MNI-space conversions (busy...)';
offfigtit='ACPC/MNI-space conversions';
case 'group'
sz=get(fighandle,'Position');
pos=[sz(3)-50-5 sz(4)-50 50 50];
onfigtit='Lead Group Analysis (busy...)';
offfigtit='Lead Group Analysis';
case 'reco'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Manual reconstruction (busy...)';
offfigtit='Manual reconstruction';
case 'stim'
sz=get(fighandle,'Position');
pos=[sz(3)-50 sz(4)-39 50 50];
onfigtit='Stimulation Parameters (busy...)';
offfigtit='Stimulation Parameters';
case 'wavelet'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Wavelet-Based Image Fusion (busy...)';
offfigtit='Wavelet-Based Image Fusion';
case 'normcheck'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
case 'normcheckstructures'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Check registration of specific structures (busy...)';
offfigtit='Check registration of specific structures';
case 'trajectory'
sz=get(fighandle,'Position');
pos=[sz(3)-50-2 sz(4)-50-2 50 50];
onfigtit='Edit Trajectory (busy...)';
offfigtit='Edit Trajectory';
end
end
switch onoff
case 'on'
if ~exist('onfigtit','var')
figtit=get(fighandle,'Name');
set(fighandle,'name',[figtit,' (busy...)']);
else
set(fighandle,'name',onfigtit);
end
spinner=getappdata(fighandle,'spinner');
if isempty(spinner)
try
% R2010a and newer
iconsClassName = 'com.mathworks.widgets.BusyAffordance$AffordanceSize';
iconsSizeEnums = javaMethod('values',iconsClassName);
SIZE_32x32 = iconsSizeEnums(2); % (1) = 16x16, (2) = 32x32
spinner = com.mathworks.widgets.BusyAffordance(SIZE_32x32, 'Busy'); % icon, label
catch
% R2009b and earlier
redColor = java.awt.Color(1,0,0);
blackColor = java.awt.Color(0,0,0);
spinner = com.mathworks.widgets.BusyAffordance(redColor, blackColor);
end
spinner.getComponent.setBackground(java.awt.Color(1, 1, 1));
spinner.setPaintsWhenStopped(true); % default = false
spinner.useWhiteDots(false); % default = false (true is good for dark backgrounds)
end
ea_javacomponent(spinner.getComponent, pos, fighandle);
spinner.setBusyText('Busy');
spinner.start;
setappdata(fighandle,'spinner',spinner);
% lock mouse pointer in non-dev environment:
prefs = ea_prefs;
if ~prefs.env.dev
set(fighandle, 'pointer', 'watch');
end
drawnow;
case 'off'
if ~exist('offfigtit','var')
figtit=get(fighandle,'Name');
set(fighandle,'name',strrep(figtit,' (busy...)', ''));
else
set(fighandle,'name',offfigtit);
end
spinner=getappdata(fighandle,'spinner');
spinner.stop;
spinner.setBusyText('Idle');
%spinner.getComponent.setVisible(false);
% change mousewheel, too:
set(fighandle, 'pointer', 'arrow');
disp('** Process done.');
case 'del'
if ~exist('offfigtit','var')
figtit=get(fighandle,'Name');
set(fighandle,'name',strrep(figtit,' (busy...)', ''));
else
set(fighandle,'name',offfigtit);
end
spinner=getappdata(fighandle,'spinner');
spinner.stop;
spinner.setBusyText('Idle');
spinner.getComponent.setBackground(java.awt.Color(0,0,0));
[hjObj, hContainer] = ea_javacomponent(spinner.getComponent, pos, fighandle);
delete(hContainer);
spinner.getComponent.setVisible(false)
setappdata(fighandle,'spinner',[]);
% change mousewheel, too:
set(fighandle, 'pointer', 'arrow');
disp('** Process done.');
end
end