0001 function ltpdv_buildFilterPanel(panH, mainfig)
0002
0003 Gproperties = getappdata(mainfig, 'Gproperties');
0004
0005 pmarg = 0.025;
0006 Hmargin = 0.05;
0007 Vmargin = 0.05;
0008
0009
0010
0011
0012
0013 Tleft = pmarg+0.3;
0014 Tbottom = 0.17;
0015 Theight = 1-pmarg - Tbottom;
0016 Twidth = 1-Tleft-pmarg;
0017
0018 panh = uipanel('Parent', panH, ...
0019 'Backgroundcolor', [0.8 0.8 0.8], ...
0020 'Units','normalized',...
0021 'Position',[Tleft Tbottom Twidth Theight]);
0022
0023 Tleft = pmarg;
0024 Tbottom = pmarg;
0025 Twidth = 1-2*pmarg;
0026 Theight = 1-2*pmarg;
0027 htab = uitabgroup('Parent', panh, ...
0028 'Units','normalized',...
0029 'Position',[Tleft Tbottom Twidth Theight]);
0030 t1 = uitab(htab, 'title', 'Standard');
0031 t2 = uitab(htab, 'title', 'File');
0032 t3 = uitab(htab, 'title', 'Object');
0033 t4 = uitab(htab, 'title', 'Poles/Zeros');
0034
0035
0036
0037 buildFilterStandardPanel(t1, mainfig);
0038
0039 buildFilterFilePanel(t2, mainfig);
0040
0041 buildFilterObjectPanel(t3, mainfig);
0042
0043 buildFilterPoleZeroPanel(t4, mainfig);
0044
0045
0046
0047 bl = pmarg;
0048 bh = 0.025;
0049 bb = 1-pmarg-bh;
0050 bw = 0.3-2*pmarg;
0051 sth = uicontrol(panH, 'Style','text',...
0052 'String', 'Filters',...
0053 'Units', 'normalized', ...
0054 'BackgroundColor', 'w', ...
0055 'Fontsize', 12, ...
0056 'Position',[bl bb bw bh]);
0057
0058 ll = pmarg;
0059 lh = 0.5;
0060 lb = bb-pmarg-lh;
0061 lw = 0.3-2*pmarg;
0062 lh = uicontrol(panH, 'Style', 'listbox', ...
0063 'String', ' ',...
0064 'BackgroundColor', 'w', ...
0065 'Value', 1, 'Units', 'normalized', ...
0066 'min', 1, 'max', 1000, ...
0067 'Fontsize', 14, ...
0068 'Tag', 'LTPDVfilterList', ...
0069 'Callback', {@ltpdv_filter_list_select, mainfig}, ...
0070 'Position',[ll lb lw lh]);
0071
0072
0073 bl = pmarg;
0074 bh = 0.05;
0075 bb = lb - bh;
0076 pbh = uicontrol(panH,'Style','pushbutton',...
0077 'String','Add Filter',...
0078 'Callback', {@ltpdv_filterAdd, htab, mainfig}, ...
0079 'Units', 'normalized', ...
0080 'Position',[bl bb bw bh]);
0081
0082
0083 bl = pmarg;
0084 bb = bb - bh;
0085 pbh = uicontrol(panH,'Style','pushbutton',...
0086 'String','Delete Filter',...
0087 'Callback', {@ltpdv_filterDelete, htab, mainfig}, ...
0088 'Units', 'normalized', ...
0089 'Position',[bl bb bw bh]);
0090
0091
0092 bl = pmarg;
0093 bb = bb - bh;
0094 pbh = uicontrol(panH,'Style','pushbutton',...
0095 'String','Clear Filters',...
0096 'Callback', {@ltpdv_filtersClear, htab, mainfig}, ...
0097 'Units', 'normalized', ...
0098 'Position',[bl bb bw bh]);
0099
0100
0101 bw = 0.15;
0102 bl = Hmargin;
0103 bb = 2*pmarg+bh;
0104 pbh = uicontrol(panH,'Style','pushbutton',...
0105 'String','Apply Filters',...
0106 'Callback', {@ltpdv_filterApply, htab, mainfig}, ...
0107 'Units', 'normalized', ...
0108 'Position',[bl bb bw bh]);
0109
0110
0111 bl = Hmargin;
0112 bb = pmarg;
0113 pbh = uicontrol(panH,'Style','pushbutton',...
0114 'String','Store Filters',...
0115 'Callback', {@ltpdv_storeFilter, htab, mainfig}, ...
0116 'Units', 'normalized', ...
0117 'Position',[bl bb bw bh]);
0118
0119
0120 bl = bl + bw + pmarg;
0121 bb = 2*pmarg+bh;
0122 pbh = uicontrol(panH,'Style','pushbutton',...
0123 'String','Plot Filter Resps',...
0124 'Callback', {@ltpdv_plotFilterResp, htab, mainfig}, ...
0125 'Units', 'normalized', ...
0126 'Position',[bl bb bw bh]);
0127
0128
0129 bb = pmarg;
0130 pbh = uicontrol(panH,'Style','pushbutton',...
0131 'String','Store Filter Resps',...
0132 'Callback', {@ltpdv_storeFilterResp, htab, mainfig}, ...
0133 'Units', 'normalized', ...
0134 'Position',[bl bb bw bh]);
0135
0136
0137 tw = 0.1;
0138 bl = bl + bw + pmarg;
0139 bw = 0.15;
0140 bb = 2*pmarg+bh;
0141 sth = uicontrol(panH, 'Style','text',...
0142 'String', 'Start F',...
0143 'Units', 'normalized', ...
0144 'BackgroundColor', 'w', ...
0145 'Fontsize', 12, ...
0146 'Position',[bl bb tw bh]);
0147 bl = bl+tw+pmarg;
0148 sth = uicontrol(panH, 'Style','edit',...
0149 'String', '',...
0150 'Units', 'normalized', ...
0151 'BackgroundColor', 'w', ...
0152 'Fontsize', 12, ...
0153 'Tag', 'LTPDVfilterF1', ...
0154 'Position',[bl bb bw bh]);
0155
0156
0157
0158 bb = pmarg;
0159 bl = bl -tw-pmarg;
0160 sth = uicontrol(panH, 'Style','text',...
0161 'String', 'Stop F',...
0162 'Units', 'normalized', ...
0163 'BackgroundColor', 'w', ...
0164 'Fontsize', 12, ...
0165 'Position',[bl bb tw bh]);
0166 bl = bl+tw+pmarg;
0167 sth = uicontrol(panH, 'Style','edit',...
0168 'String', '',...
0169 'Units', 'normalized', ...
0170 'BackgroundColor', 'w', ...
0171 'Fontsize', 12, ...
0172 'Tag', 'LTPDVfilterF2', ...
0173 'Position',[bl bb bw bh]);
0174
0175
0176 bl = bl + bw + pmarg;
0177 bb = 2*pmarg+bh;
0178 sth = uicontrol(panH, 'Style','text',...
0179 'String', 'Num f',...
0180 'Units', 'normalized', ...
0181 'BackgroundColor', 'w', ...
0182 'Fontsize', 12, ...
0183 'Position',[bl bb tw bh]);
0184 bl = bl+tw+pmarg;
0185 sth = uicontrol(panH, 'Style','edit',...
0186 'String', '',...
0187 'Units', 'normalized', ...
0188 'BackgroundColor', 'w', ...
0189 'Fontsize', 12, ...
0190 'Tag', 'LTPDVfilterNf', ...
0191 'Position',[bl bb bw bh]);
0192
0193
0194 bb = pmarg;
0195 bl = bl -tw-pmarg;
0196 sth = uicontrol(panH, 'Style','text',...
0197 'String', 'Scale',...
0198 'Units', 'normalized', ...
0199 'BackgroundColor', 'w', ...
0200 'Fontsize', 12, ...
0201 'Position',[bl bb tw bh]);
0202 bl = bl+tw+pmarg;
0203 sth = uicontrol(panH, 'Style','popupmenu',...
0204 'String', {'log', 'lin'},...
0205 'Units', 'normalized', ...
0206 'BackgroundColor', 'w', ...
0207 'Fontsize', 12, ...
0208 'Tag', 'LTPDVfilterScale', ...
0209 'Position',[bl bb bw bh]);
0210
0211
0212
0213
0214 function buildFilterPoleZeroPanel(panH, mainfig)
0215
0216 pmarg = 0.025;
0217
0218
0219 bl = pmarg;
0220 bw = 0.15;
0221 tw = 0.2;
0222 bh = 0.05;
0223 bb = 1 - bh - pmarg;
0224 sth = uicontrol(panH, 'Style','text',...
0225 'String', 'Freq [Hz]',...
0226 'Units', 'normalized', ...
0227 'BackgroundColor', 'w', ...
0228 'Fontsize', 12, ...
0229 'Position',[bl bb tw bh]);
0230 bl = bl+tw+pmarg;
0231 sth = uicontrol(panH, 'Style','edit',...
0232 'String', '',...
0233 'Units', 'normalized', ...
0234 'BackgroundColor', 'w', ...
0235 'Fontsize', 12, ...
0236 'Tag', 'LTPDVfilterPZfreq', ...
0237 'Position',[bl bb bw bh]);
0238
0239
0240 bl = bl + bw + pmarg;
0241 bb = 1 - bh - pmarg;
0242 sth = uicontrol(panH, 'Style','text',...
0243 'String', 'Q',...
0244 'Units', 'normalized', ...
0245 'BackgroundColor', 'w', ...
0246 'Fontsize', 12, ...
0247 'Position',[bl bb tw/2 bh]);
0248 bl = bl+tw+pmarg;
0249 sth = uicontrol(panH, 'Style','edit',...
0250 'String', '',...
0251 'Units', 'normalized', ...
0252 'BackgroundColor', 'w', ...
0253 'Fontsize', 12, ...
0254 'Tag', 'LTPDVfilterPZq', ...
0255 'Position',[bl bb bw bh]);
0256
0257
0258 pl = pmarg;
0259 pw = 0.5 - 2*pmarg;
0260 ph = 0.6;
0261 pb = bb - pmarg - ph;
0262 poleh = uipanel(panH, 'Title', 'Poles', ...
0263 'Units', 'normalized', ...
0264 'Position', [pl pb pw ph]);
0265
0266 bl = pmarg;
0267 bh = 0.07;
0268 bb = 1-bh-pmarg;
0269 bw = 1-2*pmarg;
0270 pbh = uicontrol(poleh,'Style','pushbutton',...
0271 'String','Add',...
0272 'Callback', {@ltpdv_poleAdd, htab, mainfig}, ...
0273 'Units', 'normalized', ...
0274 'Position',[bl bb bw bh]);
0275
0276
0277 ll = pmarg;
0278 lh = 0.7;
0279 lb = bb-lh-pmarg;
0280 lw = 1-2*pmarg;
0281 lh = uicontrol(poleh, 'Style', 'listbox', ...
0282 'String', ' ',...
0283 'BackgroundColor', 'w', ...
0284 'Value', 1, 'Units', 'normalized', ...
0285 'Fontsize', 14, ...
0286 'Tag', 'LTPDVfilterPolelist', ...
0287 'max', 1000, ...
0288 'Position',[ll lb lw lh]);
0289
0290
0291 bl = pmarg;
0292 bb = lb-pmarg-bh;
0293 pbh = uicontrol(poleh,'Style','pushbutton',...
0294 'String','Delete',...
0295 'Callback', {@ltpdv_poleDelete, htab, mainfig}, ...
0296 'Units', 'normalized', ...
0297 'Position',[bl bb bw bh]);
0298
0299 bl = pmarg;
0300 bb = bb-bh;
0301 pbh = uicontrol(poleh,'Style','pushbutton',...
0302 'String','Clear',...
0303 'Callback', {@ltpdv_poleClear, htab, mainfig}, ...
0304 'Units', 'normalized', ...
0305 'Position',[bl bb bw bh]);
0306
0307
0308 pl = 0.5 + pmarg;
0309 zeroh = uipanel(panH, 'Title', 'Zeros', ...
0310 'Units', 'normalized', ...
0311 'Position', [pl pb pw ph]);
0312
0313 bl = pmarg;
0314 bh = 0.07;
0315 bb = 1-bh-pmarg;
0316 bw = 1-2*pmarg;
0317 pbh = uicontrol(zeroh,'Style','pushbutton',...
0318 'String','Add',...
0319 'Callback', {@ltpdv_zeroAdd, htab, mainfig}, ...
0320 'Units', 'normalized', ...
0321 'Position',[bl bb bw bh]);
0322
0323 ll = pmarg;
0324 lh = 0.7;
0325 lb = bb-lh-pmarg;
0326 lw = 1-2*pmarg;
0327 lh = uicontrol(zeroh, 'Style', 'listbox', ...
0328 'String', ' ',...
0329 'BackgroundColor', 'w', ...
0330 'Value', 1, 'Units', 'normalized', ...
0331 'Fontsize', 14, ...
0332 'Tag', 'LTPDVfilterZerolist', ...
0333 'max', 1000, ...
0334 'Position',[ll lb lw lh]);
0335
0336 bl = pmarg;
0337 bb = lb-pmarg-bh;
0338 pbh = uicontrol(zeroh,'Style','pushbutton',...
0339 'String','Delete',...
0340 'Callback', {@ltpdv_zeroDelete, htab, mainfig}, ...
0341 'Units', 'normalized', ...
0342 'Position',[bl bb bw bh]);
0343
0344 bl = pmarg;
0345 bb = bb-bh;
0346 pbh = uicontrol(zeroh,'Style','pushbutton',...
0347 'String','Clear',...
0348 'Callback', {@ltpdv_zeroClear, htab, mainfig}, ...
0349 'Units', 'normalized', ...
0350 'Position',[bl bb bw bh]);
0351
0352
0353 pos = get(zeroh, 'Position');
0354 bl = pmarg;
0355 bw = 0.15;
0356 tw = 0.15;
0357 bh = 0.06;
0358 bb = pos(2) - bh - pmarg;
0359 sth = uicontrol(panH, 'Style','text',...
0360 'String', 'Gain',...
0361 'Units', 'normalized', ...
0362 'BackgroundColor', 'w', ...
0363 'Fontsize', 12, ...
0364 'Position',[bl bb tw bh]);
0365 bl = bl+tw+pmarg;
0366 sth = uicontrol(panH, 'Style','edit',...
0367 'String', '',...
0368 'Units', 'normalized', ...
0369 'BackgroundColor', 'w', ...
0370 'Fontsize', 12, ...
0371 'Tag', 'LTPDVfilterPZgain', ...
0372 'Position',[bl bb bw bh]);
0373
0374
0375 bl = bl + bw + pmarg;
0376 sth = uicontrol(panH, 'Style','text',...
0377 'String', 'Name',...
0378 'Units', 'normalized', ...
0379 'BackgroundColor', 'w', ...
0380 'Fontsize', 12, ...
0381 'Position',[bl bb tw bh]);
0382 bl = bl+tw+pmarg;
0383 bw = 0.3;
0384 sth = uicontrol(panH, 'Style','edit',...
0385 'String', '',...
0386 'Units', 'normalized', ...
0387 'BackgroundColor', 'w', ...
0388 'Fontsize', 12, ...
0389 'Tag', 'LTPDVfilterPZname', ...
0390 'Position',[bl bb bw bh]);
0391
0392
0393 bb = bb - bh - pmarg;
0394 bl = pmarg;
0395 bw = 0.22;
0396 pbh = uicontrol(panH,'Style','pushbutton',...
0397 'String','Plot response',...
0398 'Callback', {@ltpdv_pzmResp, panH, mainfig}, ...
0399 'Units', 'normalized', ...
0400 'Position',[bl bb bw bh]);
0401
0402
0403
0404 bl = bl+bw+pmarg;
0405 pbh = uicontrol(panH,'Style','pushbutton',...
0406 'String','Store model',...
0407 'Callback', {@ltpdv_pzmStore, panH, mainfig}, ...
0408 'Units', 'normalized', ...
0409 'Position',[bl bb bw bh]);
0410
0411
0412 bl = bl+bw+pmarg;
0413 pbh = uicontrol(panH,'Style','pushbutton',...
0414 'String','Store model resp',...
0415 'Callback', {@ltpdv_pzmStoreResp, panH, mainfig}, ...
0416 'Units', 'normalized', ...
0417 'Position',[bl bb bw bh]);
0418
0419 end
0420
0421
0422 function buildFilterObjectPanel(panH, mainfig)
0423
0424 pmarg = 0.025;
0425
0426
0427 bl = pmarg;
0428 bh = 0.04;
0429 bw = 0.2;
0430 bb = 1 - bh - pmarg;
0431 pbh = uicontrol(panH,'Style','pushbutton',...
0432 'String','Import Filter',...
0433 'Callback', {@ltpdv_filterImport, panH, mainfig}, ...
0434 'Units', 'normalized', ...
0435 'Position',[bl bb bw bh]);
0436
0437
0438
0439 tl = pmarg;
0440 tw = 1 - 2*pmarg;
0441 th = bb - 2*pmarg;
0442 tb = pmarg;
0443 ph = uipanel(panH, 'Title', 'Imported Filter', ...
0444 'Units', 'normalized', ...
0445 'Fontsize', 12, ...
0446 'Position', [tl tb tw th]);
0447
0448 tl = pmarg;
0449 tb = pmarg;
0450 tw = 1 - 2*pmarg;
0451 th = 1 - 2*pmarg;
0452 fh = uicontrol(ph, 'Style', 'text', ...
0453 'String', '', ...
0454 'HorizontalAlignment', 'left', ...
0455 'Units', 'normalized', ...
0456 'Fontsize', 12, ...
0457 'FontName', 'monospace', ...
0458 'BackgroundColor', 'w', ...
0459 'Tag', 'LTPDVfilterObjectInfo', ...
0460 'Position', [tl tb tw th]);
0461
0462 end
0463
0464
0465 function buildFilterFilePanel(panH, mainfig)
0466
0467 pmarg = 0.025;
0468
0469
0470 tl = pmarg;
0471 th = 0.05;
0472 tw = 0.15;
0473 tb = 1 - pmarg - th;
0474 sth = uicontrol(panH, 'Style','text',...
0475 'String', 'Filename',...
0476 'Units', 'normalized', ...
0477 'BackgroundColor', 'w', ...
0478 'Fontsize', 12, ...
0479 'Position',[tl tb tw th]);
0480
0481
0482 tl = tl + tw + pmarg;
0483 th = 0.05;
0484 tw = 0.5;
0485 tb = 1 - pmarg - th;
0486 sth = uicontrol(panH, 'Style','edit',...
0487 'String', '',...
0488 'Units', 'normalized', ...
0489 'BackgroundColor', 'w', ...
0490 'Fontsize', 12, ...
0491 'Tag', 'LTPDVfilterFileFilename', ...
0492 'Position',[tl tb tw th]);
0493
0494
0495 tl = tl + tw + pmarg;
0496 th = 0.05;
0497 tw = 0.2;
0498 tb = 1 - pmarg - th;
0499 sth = uicontrol(panH, 'Style','pushbutton',...
0500 'String', 'Browse',...
0501 'Units', 'normalized', ...
0502 'Fontsize', 12, ...
0503 'Callback', {@ltpdv_filterBrowse, panH, mainfig}, ...
0504 'Position', [tl tb tw th]);
0505
0506
0507 tl = pmarg;
0508 tw = 1 - 2*pmarg;
0509 th = tb - 2*pmarg;
0510 tb = pmarg;
0511 ph = uipanel(panH, 'Title', 'Loaded Filter', ...
0512 'Units', 'normalized', ...
0513 'Fontsize', 12, ...
0514 'Position', [tl tb tw th]);
0515
0516 tl = pmarg;
0517 tb = pmarg;
0518 tw = 1 - 2*pmarg;
0519 th = 1 - 2*pmarg;
0520 fh = uicontrol(ph, 'Style', 'text', ...
0521 'String', '', ...
0522 'HorizontalAlignment', 'left', ...
0523 'Units', 'normalized', ...
0524 'Fontsize', 12, ...
0525 'FontName', 'monospace', ...
0526 'BackgroundColor', 'w', ...
0527 'Tag', 'LTPDVfilterFileInfo', ...
0528 'Position', [tl tb tw th]);
0529
0530
0531
0532 end
0533
0534
0535 function buildFilterStandardPanel(panH, mainfig)
0536
0537 filts = {'Lowpass', 'Highpass', 'Bandpass', 'Bandreject'};
0538
0539 pmarg = 0.025;
0540
0541
0542
0543 pl = pmarg;
0544 ph = 0.05;
0545 pb = 1 - ph - 2*pmarg;
0546 pw = 0.4;
0547 eh = uicontrol(panH,'Style','popupmenu',...
0548 'String', filts,...
0549 'units', 'normalized', ...
0550 'BackgroundColor', 'w', ...
0551 'Fontsize', 12, ...
0552 'Enable', 'on', ...
0553 'Tag', 'LTPDVfiltStandardType', ...
0554 'Position',[pl pb pw ph]);
0555
0556
0557 addEntry(panH, 'Gain', 1, pmarg, pl, pb, pw, ph);
0558
0559 pb = pb - ph - pmarg;
0560 addEntry(panH, 'Cutoff', 0.1, pmarg, pl, pb, pw, ph);
0561
0562 pb = pb - ph - pmarg;
0563 addEntry(panH, 'Fs', 1, pmarg, pl, pb, pw, ph);
0564
0565 pb = pb - ph - pmarg;
0566 addEntry(panH, 'Order', 1, pmarg, pl, pb, pw, ph);
0567
0568 pb = pb - ph - pmarg;
0569 addEntry(panH, 'Ripple', 0.5, pmarg, pl, pb, pw, ph);
0570
0571
0572
0573 end
0574
0575 function addEntry(panH, str, val, pmarg, pl, pb, pw, ph)
0576
0577 pl = pmarg;
0578 pb = pb - ph - pmarg;
0579 sth = uicontrol(panH,'Style','text',...
0580 'String', str,...
0581 'Units', 'normalized', ...
0582 'BackgroundColor', 'w', ...
0583 'Fontsize', 12, ...
0584 'Position',[pl pb pw ph]);
0585 pl = 2*pmarg + pw;
0586 eh = uicontrol(panH,'Style','edit',...
0587 'String', val,...
0588 'units', 'normalized', ...
0589 'BackgroundColor', 'w', ...
0590 'Fontsize', 12, ...
0591 'Enable', 'on', ...
0592 'Tag', sprintf('LTPDVfiltStandard%s', str), ...
0593 'Position',[pl pb pw ph]);
0594
0595 end
0596
0597 end