-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfm_dir.m
361 lines (325 loc) · 11.1 KB
/
fm_dir.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
function fig = fm_dir(flag)
% FM_DIR create GUI for data format conversion
%
% HDL = FM_DIR(FLAG)
% FLAG = 0: DATA CONVERISON
% FLAG = 1: OPEN DATA FILE
% FLAG = 2: OPEN PERTURBATION FILE
% FLAG = 3: OPEN ANY FILE
%
%see also FM_DIRSET
%
%Author: Federico Milano
%Date: 11-Nov-2002
%Update: 31-Jul-2003
%Update: 07-Oct-2003
%Version: 1.1.0
%
%E-mail: [email protected]
%Web-site: faraday1.ucd.ie/psat.html
%
% Copyright (C) 2002-2019 Federico Milano
global Settings Path Theme Fig File
if ishandle(Fig.dir), figure(Fig.dir), return, end
frompsat = {'IEEE CDF'; 'EPRI-WECC'; 'ODM'};
h0 = figure( ...
'Color',Theme.color01, ...
'Units', 'normalized', ...
'ColorMap', [], ...
'ResizeFcn','fm_dirset chformat', ...
'CreateFcn','Fig.dir = gcf;', ...
'DeleteFcn','Fig.dir = -1;', ...
'FileName','fm_dir', ...
'MenuBar','none', ...
'Name','Data Conversion', ...
'NumberTitle','off', ...
'PaperPosition',[18 180 576 432], ...
'PaperUnits','points', ...
'Position',sizefig(1.1*0.5375,1.1*0.5068), ...
'ToolBar','none');
if Settings.hostver < 7.05
set(h0,'ShareColors','on')
end
fm_set colormap
if flag == 1, set(h0,'Name','Load Data File'), end
if flag == 2, set(h0,'Name','Load Perturbation File'), end
if flag == 3, set(h0,'Name','Open File'), end
h1 = axes( ...
'Parent',h0, ...
'Box','on', ...
'CameraUpVector',[0 1 0], ...
'CameraUpVectorMode','manual', ...
'Color',Theme.color04, ...
'ColorOrder',Settings.color, ...
'SortMethod','depth', ...
'Layer','top', ...
'NextPlot','add', ...
'Position',[0.7393 0.4016 0.1931 0.3411], ...
'Tag','Axes1', ...
'XColor',[0 0 0], ...
'XLim',[0.5 117.5], ...
'XLimMode','manual', ...
'XTickLabelMode','manual', ...
'XTickMode','manual', ...
'YColor',[0 0 0], ...
'YDir','reverse', ...
'YLim',[0.5 147.5], ...
'YLimMode','manual', ...
'YTickLabelMode','manual', ...
'YTickMode','manual', ...
'ZColor',[0 0 0]);
a = imread([Path.images,'logo_ieee.jpg'],'jpg');
h2 = image( ...
'Parent',h1, ...
'CData',a, ...
'Tag','Axes1Image1', ...
'XData',[1 117], ...
'YData',[1 147]);
%'Erase','none', ...
h1 = uicontrol( ...
'Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color02, ...
'Callback','fm_dirset preview', ...
'Position',[0.70349 0.77842 0.1 0.05], ...
'String','Preview', ...
'Visible','off', ...
'Enable','off', ...
'Tag','PushbuttonPreview');
h1 = uicontrol( ...
'Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color04, ...
'Callback','fm_dirset diredit', ...
'CreateFcn', 'fm_dirset editinit', ...
'FontName',Theme.font01, ...
'HorizontalAlignment','left', ...
'Position',[0.18023 0.88054 0.7 0.052023], ...
'String',pwd, ...
'Style','edit', ...
'Tag','EditText1');
if strcmp(Settings.platform,'MAC')
set(h1, ...
'Position',[0.18023 0.88054 0.7 0.062023], ...
'HorizontalAlignment','center')
end
h1 = uicontrol( ...
'Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color03, ...
'Callback','fm_dirset convert', ...
'FontWeight','bold', ...
'ForegroundColor',Theme.color09, ...
'Position',[0.70349 0.25626 0.26163 0.090559], ...
'String','Convert', ...
'Tag','Pushbutton1');
if flag, set(h1,'String','Load','Callback','fm_dirset openfile'), end
hpop = uicontrol( ...
'Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color04, ...
'ForegroundColor',Theme.color05, ...
'Callback','fm_dirset chformat', ...
'Position',[0.039244 0.33333-0.015 0.27035 0.055462], ...
'String',fm_dirset('formatlist'), ...
'UserData', flag, ...
'Style','popupmenu', ...
'Tag','PopupMenu1', ...
'Value',1);
str = 'if strcmp(get(Fig.dir,''SelectionType''),''open''),fm_dirset view,end';
h1 = uicontrol( ...
'Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color04, ...
'ButtonDownFcn','fm_dirset convert', ...
'Callback', str, ...
'FontName',Theme.font01, ...
'ForegroundColor',Theme.color07, ...
'Max',201, ...
'Position',[0.37064 0.050096 0.2718 0.69364], ...
'Style','listbox', ...
'String',cell(0,1), ...
'ListboxTop',1, ...
'Tag','Listbox2', ...
'Value',1);
if flag, set(h1,'Max',0,'ButtonDownFcn','fm_dirset openfile'), end
% checkboxes
h1 = uicontrol( ...
'Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color01, ...
'Position',[0.039244 0.050096 0.27035 0.055462], ...
'String','Silent conversion', ...
'TooltipString','Do not ask for additional files for data conversion', ...
'Style','checkbox', ...
'Tag','CheckboxSilent', ...
'Value',0);
h1 = uicontrol( ...
'Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color01, ...
'Position',[0.039244 0.12 0.27035 0.055462], ...
'String','Verbose conversion', ...
'TooltipString','Print additional comments during data conversion', ...
'Style','checkbox', ...
'Tag','CheckboxVerbose', ...
'Value',0);
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color01, ...
'HorizontalAlignment','left', ...
'Position',[0.039244 0.25 0.2718 0.036609], ...
'Enable','off', ...
'String','Translate PSAT file to:', ...
'Style','text', ...
'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color01, ...
'Position',[0.039244 0.20424-0.015 0.27035 0.055462], ...
'Enable','off', ...
'String',frompsat, ...
'Style','popupmenu', ...
'Tag','Checkbox2', ...
'Value', 1);
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color01, ...
'HorizontalAlignment','left', ...
'Position',[0.039244 0.88247 0.13081 0.050096], ...
'String','Current path:', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color01, ...
'HorizontalAlignment','left', ...
'Position',[0.039244 0.77842 0.27035 0.050096], ...
'String','Folders in current path:', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color01, ...
'HorizontalAlignment','left', ...
'Position',[0.039244 0.38536 0.2718 0.036609], ...
'String','Filters:', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color01, ...
'HorizontalAlignment','left', ...
'Position',[0.37064 0.77842 0.2718 0.050096], ...
'String','Files in current path:', ...
'Style','text', ...
'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color04, ...
'ButtonDownFcn','fm_dirset changedir', ...
'Callback', 'fm_dirset dirsel', ...
'CreateFcn','fm_dirset dirinit', ...
'FontName',Theme.font01, ...
'ForegroundColor',Theme.color05, ...
'Max',201, ...
'Position',[0.039244 0.45279 0.2718 0.29094], ...
'String', cell(0,1), ...
'ListboxTop',1, ...
'Style','listbox', ...
'Tag','Listbox1', ...
'Value',1);
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color02, ...
'Callback','fm_dirset view', ...
'Position',[0.70349 0.15222 0.26163 0.090559], ...
'String','View File', ...
'Tag','Pushbutton2');
h1 = uicontrol('Parent',h0, ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color02, ...
'Callback', 'close(gcf);', ...
'Position',[0.70349 0.050096 0.26163 0.090559], ...
'String','Close', ...
'Tag','Pushbutton3');
if flag, set(h1,'Callback','fm_dirset cancel','String','Cancel'), end
h1 = uicontrol('Parent',h0, ...
'CData', fm_mat('misc_folder'), ...
'Units', 'normalized', ...
'BackgroundColor',Theme.color02, ...
'Callback','fm_dirset getfolder', ...
'Position',[0.9164 0.875 0.065/1.333 0.065], ...
'TooltipString','Get folder', ...
'Tag','Pushbutton4');
% Menu File
h1 = uimenu('Parent',h0, ...
'Label','File', ...
'Tag','U2');
h2 = uimenu('Parent',h1, ...
'Callback','close(gcf);', ...
'Label','Close', ...
'Tag','S24', ...
'Accelerator','x');
% Menu Edit
h1 = uimenu('Parent',h0, ...
'Label','Edit', ...
'Tag','U3');
h2 = uimenu('Parent',h1, ...
'Callback','fm_dirset convert', ...
'Label','Convert', ...
'Tag','S24', ...
'Accelerator','c');
h2 = uimenu('Parent',h1,'Callback', ...
'hdl = findobj(Fig.dir,''Tag'',''Listbox1''); set(hdl,''Value'',1), fm_dirset changedir', ...
'Label','Refresh Folder', ...
'Tag','S24', ...
'Accelerator','r', ...
'Separator','on');
h2 = uimenu('Parent',h1, ...
'Callback','fm_dirset changedir', ...
'Label','Change Folder', ...
'Tag','S24', ...
'Accelerator','z');
h2 = uimenu('Parent',h1, ...
'Callback','fm_dirset getfolder', ...
'Label','Get Folder', ...
'Tag','S24', ...
'Accelerator','g');
h2 = uimenu('Parent',h1, ...
'Callback', 'hdl = findobj(Fig.dir,''Tag'',''Listbox1''); set(hdl,''Value'',2), fm_dirset changedir', ...
'Label','Back Folder', ...
'Tag','S24', ...
'Accelerator','b');
% Menu View
h1 = uimenu('Parent',h0, ...
'Label','View', ...
'Tag','U3');
h2 = uimenu('Parent',h1, ...
'Callback','fm_dirset view', ...
'Label','View File', ...
'Tag','S24', ...
'Accelerator','v');
h2 = uimenu('Parent',h1, ...
'Callback','fm_dirset preview', ...
'Label','Preview Simulink model', ...
'Tag','Preview', ...
'Accelerator','p');
h2 = uimenu('Parent',h1, ...
'Callback','fm_tviewer', ...
'Label','Text Viewer', ...
'Tag','OTV', ...
'Accelerator','t');
switch flag
case 0
set(hpop,'Value',Settings.format)
case 1
set(hpop,'Value',Settings.format)
case 2
set(hpop,'Value',3,'Enable','inactive')
case 3
string = get(hpop,'String');
set(hpop,'Value',length(string),'Enable','inactive')
end
fm_dirset chformat
if nargout > 0, fig = h0; end