-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfm_clock.m
234 lines (220 loc) · 5.86 KB
/
fm_clock.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
function fm_clock(varargin)
% FM_CLOCK create a clock
%
%Author: Federico Milano
%Date: 11-Nov-2002
%Update: 10-Feb-2003
%Version: 1.0.2
%
%E-mail: [email protected]
%Web-site: faraday1.ucd.ie/psat.html
%
% Copyright (C) 2002-2019 Federico Milano
global Fig Settings Theme
if nargin
switch varargin{1}
case 'keyesc'
tasto = get(gcf,'CurrentCharacter');
if (double(tasto) == 13 || double(tasto) == 27),
delete(gcf);
end
end
return
end
if isunix
fontname = 'Times';
else
fontname = 'Times New Roman';
end
month = {'Jan';'Feb';'Mar';'Apr';'May';'Jun';'Jul';'Aug';'Sep';'Oct';'Nov';'Dec'};
a = clock;
if ishandle(Fig.clock), return, end
h0 = figure('Color',Theme.color01, ...
'Units', 'normalized', ...
'Colormap',[], ...
'CreateFcn','Fig.clock = gcf;', ...
'DeleteFcn','close(Fig.clock)', ...
'KeyPressFcn','fm_clock keyesc', ...
'FileName','fm_clock', ...
'MenuBar','none', ...
'Name','Clock', ...
'NumberTitle','off', ...
'PaperPosition',[18 180 576 432], ...
'PaperType','A4', ...
'PaperUnits','points', ...
'Position',sizefig(0.2450,0.3333), ...
'Userdata', 1, ...
'Resize','on', ...
'ToolBar','none', ...
'WindowButtonDownFcn','set(Fig.clock,''Userdata'',-1)');
h1 = axes('Parent',h0, ...
'Box','on', ...
'CameraUpVector',[0 1 0], ...
'CameraUpVectorMode','manual', ...
'Color',Theme.color04, ...
'ColorOrder',Settings.color, ...
'Layer','top', ...
'Position',[0.1 0.1 0.8 0.8], ...
'Tag','Axes1', ...
'XColor',[0 0.251 0.502], ...
'XLim',[0.5 200.5], ...
'XLimMode','manual', ...
'XTick',[], ...
'XTickLabelMode','manual', ...
'YColor',[0 0.251 0.502], ...
'YDir','reverse', ...
'YLim',[0.5 167.5], ...
'YLimMode','manual', ...
'YTickLabelMode','manual', ...
'YTick',[], ...
'ZColor',[0 0 0]);
hdata = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color01, ...
'Enable','inactive', ...
'FontName',fontname, ...
'FontSize',10, ...
'FontWeight','bold', ...
'ForegroundColor',Theme.color05, ...
'Position',[0.65 0.0 0.3 0.1], ...
'String',[num2str(a(3)),' ',month{a(2)},' ',num2str(a(1))], ...
'Style','text', ...
'Tag','TextDate');
day = a(3);
t = 0:0.01:2*pi+0.01;
x = cos(t);
y = sin(t);
plot(x,y,'k');
patch(x,y,Theme.color04)
hold on
plot(0.035*x,0.035*y,'k');
h = text(0,0.775*sin(pi/6),'PSAT');
set(h, ...
'FontName',fontname, ...
'FontSize',10, ...
'FontAngle','oblique', ...
'FontWeight','bold', ...
'HorizontalAlignment','center')
for i = 1:12
ang = pi/2-pi*i/6;
h = plot([0.95*cos(ang) cos(ang)], ...
[0.95*sin(ang) sin(ang)], 'k');
set(h,'LineWidth',2)
xt = 0.775*cos(ang);
yt = 0.775*sin(ang);
ht = text(xt,yt,num2str(i));
set(ht, ...
'FontName',fontname, ...
'FontSize',12, ...
'FontAngle','oblique', ...
'FontWeight','bold', ...
'HorizontalAlignment','center')
end
for i = 1:60
ang = pi*i/30;
plot([0.95*cos(ang) cos(ang)], ...
[0.95*sin(ang) sin(ang)],'k')
end
plot(0.95*x,0.95*y,'k');
t1 = pi/4:0.01:3*pi/4;
t2 = 3*pi/4:-0.01:pi/4;
hx = 0.05+1.2*(cos(pi/4)+[cos(t1), cos(t2)])/3;
hy = 0.07*[sin(t1)-sin(pi/4),sin(pi/4)-sin(t2)];
mx = 0.05+2*(cos(pi/4)+[cos(t1), cos(t2)])/3;
my = 0.05*[sin(t1)-sin(pi/4),sin(pi/4)-sin(t2)];
s = pi/2-pi/30*a(6);
b = a(6)/60;
if b == 1; b = 0; end
m = pi/2-pi/30*(a(5)+b);
c = a(5)/60;
if c == 1; c = 0; end
o = pi/2-pi/6*(a(4)+c);
hh = plot([hx*cos(o)-hy*sin(o)], ...
[hx*sin(o)+hy*cos(o)]);
hm = plot([mx*cos(m)-my*sin(m)], ...
[mx*sin(m)+my*cos(m)]);
hs1 = plot([0.05*cos(s) 0.98*cos(s)], ...
[0.05*sin(s) 0.98*sin(s)]);
hs2 = plot([0.05*cos(pi+s) 0.2*cos(pi+s)], ...
[0.05*sin(pi+s) 0.2*sin(pi+s)]);
if Settings.hostver > 8.04
set(hh, ...
'Color',Theme.color11)
set(hm, ...
'Color',Theme.color11)
set(hs1, ...
'Color',[0.5 0 0.5])
set(hs2, ...
'Color',[0.5 0 0.5])
set(gca, ...
'Visible','off', ...
'NextPlot','add')
else
set(hh, ...
'EraseMode','xor', ...
'Color',Theme.color11)
set(hm, ...
'EraseMode','xor', ...
'Color',Theme.color11)
set(hs1, ...
'EraseMode','xor', ...
'Color',[0.5 0 0.5])
set(hs2, ...
'EraseMode','xor', ...
'Color',[0.5 0 0.5])
set(gca, ...
'Visible','off', ...
'Drawmode','fast', ...
'NextPlot','add')
end
counter = 0;
while 1
try
a = get(Fig.clock,'Userdata');
catch
Fig.clock = -1;
break
end
if a == -1,
delete(Fig.clock)
Fig.clock = -1;
break
end
a = clock;
if a(3) ~= day
day = a(3);
set(hdata, ...
'String',[num2str(a(3)),' ', ...
month{a(2)},' ', ...
num2str(a(1))])
end
s = pi/2-pi/30*a(6);
b = a(6)/60;
if b == 1, b = 0; end
m = pi/2-pi/30*(a(5)+b);
c = a(5)/60;
if c == 1, c = 0; end
o = pi/2-pi/6*(a(4)+c);
try
if counter > 30
set(hh, ...
'Xdata',[hx*cos(o)-hy*sin(o)], ...
'Ydata',[hx*sin(o)+hy*cos(o)])
set(hm, ...
'Xdata',[mx*cos(m)-my*sin(m)], ...
'Ydata',[mx*sin(m)+my*cos(m)])
counter = 0;
end
set(hs1, ...
'Xdata',[0.05*cos(s) 0.98*cos(s)], ...
'Ydata',[0.05*sin(s) 0.98*sin(s)])
set(hs2, ...
'Xdata',[0.05*cos(pi+s) 0.2*cos(pi+s)], ...
'Ydata',[0.05*sin(pi+s) 0.2*sin(pi+s)])
catch
% clock figure has been likely closed...
break
end
pause(1/8)
counter = counter + 1;
end