📄 spectview.m
字号:
break % found it
end
end
delete(ud.lines(rmInd).h)
ud.spect(rmInd) = [];
ud.lines(rmInd) = [];
ud.SPToolIndices = ind;
set(fig,'userdata',ud)
sptlegend('setstring',{ud.spect.label},...
{ud.lines.columns},fig,1)
if ud.focusIndex == rmInd
% shift focus to first spectrum
ud.focusIndex = 1;
% save the focusline handle in the userdata struct:
ud.focusline = ud.lines(ud.focusIndex).h;
spzoomout(ud,0,0) % saves userdata
ud = get(fig,'userdata');
spectview('linedown',ud.focusIndex,0,fig,1)
else
if ud.focusIndex > rmInd
ud.focusIndex = ud.focusIndex - 1;
end
spzoomout(ud,0,0) % saves userdata
if ud.prefs.tool.ruler
ruler('showlines',fig)
end
end
end % if isempty(ind)
ud = get(fig,'userdata');
ud.inheritList = newInheritString(ud.hand.inheritPopup,...
{spect.label},ud.maxPopupEntries);
set(fig,'userdata',ud)
case 'Signal' % a signal was cleared
spectview('hotlink',changedStruc,msg,fig,SPTfig)
end
end % switch msg
end
case 'create'
sig = sptool('Signals',0,SPTfig);
if length(sig) == 1
enable = 'on';
else
enable = 'off';
end
case 'update'
sig = sptool('Signals',0,SPTfig);
spect = sptool('Spectra',0,SPTfig);
if length(sig) == 1 & length(spect) == 1
enable = 'on';
else
enable = 'off';
end
end
varargout{1} = enable;
%------------------------------------------------------------------------
% enable = spectview('action',verb.action,selection)
% respond to button push in SPTool
% possible actions are
% 'view', 'create' and 'update'
case 'action'
switch varargin{2}
case 'view'
SPTfig = gcf;
[s,ind] = sptool('Spectra',1,SPTfig); % get selected spectra
fig = findobj('type','figure','tag','spectview');
if isempty(fig) % create the spectview tool
spectview(SPTfig)
fig = gcf;
ud = get(fig,'userdata');
ud.SPToolIndices = ind;
set(fig,'userdata',ud)
else
ud = get(fig,'userdata');
end
if ~isequal(ud.spect,s(ind))
spectview('update',fig,s,ind,SPTfig,'new')
ud = get(fig,'userdata');
ud.inheritList = newInheritString(ud.hand.inheritPopup,...
{s.label},ud.maxPopupEntries);
set(fig,'userdata',ud)
end
% bring spectview figure to front:
figure(fig)
case 'create'
SPTfig = gcf;
sig = sptool('Signals',0,SPTfig); % get the selected signal
[err,errstr,struc] = importspec('make',{1 [] []});
struc.signal = [size(sig.data) ~isreal(sig.data)];
struc.signalLabel = sig.label;
struc.Fs = sig.Fs;
labelList = sptool('labelList',SPTfig);
[popupString,fields,FsFlag,defaultLabel] = importspec('fields');
struc.label = uniqueDefaultLabel(labelList,defaultLabel);
fig = findobj('type','figure','tag','spectview');
if isempty(fig) % create the spectview tool if not open
spectview(SPTfig)
fig = gcf;
end
ud = get(fig,'userdata');
sptool('import',struc,1,SPTfig) % puts new struc in SPTool AND
% focuses spectview on the struc
% now bring spectrum viewer to the front:
figure(fig)
case 'update'
SPTfig = gcf;
sig = sptool('Signals',0,SPTfig); % get the selected signal
[struc,ind] = sptool('Spectra',1,SPTfig);
fig = findobj('type','figure','tag','spectview');
if isempty(fig) % create the spectview tool if not open
spectview(SPTfig)
fig = gcf;
ud = get(fig,'userdata');
ud.SPToolIndices = ind;
set(fig,'userdata',ud)
else % bring spectrum viewer to the front:
figure(fig)
end
struc(ind).signal = [size(sig.data) ~isreal(sig.data)];
struc(ind).signalLabel = sig.label;
struc(ind).Fs = sig.Fs;
struc(ind).P = [];
struc(ind).f = [];
if ~isempty(struc(ind).confid)
struc(ind).confid.Pc = [];
end
sptool('import',struc(ind),0,SPTfig)
[spect,ind] = sptool('Spectra',1,SPTfig);
spectview('update',fig,spect,ind,SPTfig,'new')
end
%------------------------------------------------------------------------
% spectview('hotlink',changedStruc,msg,fig,SPTfig)
case 'hotlink'
changedStruc = varargin{2};
msg = varargin{3};
fig = varargin{4};
SPTfig = varargin{5};
if strcmp(msg,'value') | strcmp(msg,'dup')
return
end
if strcmp(msg,'new') & isempty(changedStruc)
% only worry about new in case of overwrite
return
end
ud = get(fig,'userdata');
[spect,spectInd] = sptool('Spectra',1,SPTfig); % all spectra in tool
linkedSpect = findcstr({spect.signalLabel},changedStruc.label);
if isempty(linkedSpect)
return
end
sigs = sptool('Signals',1,SPTfig);
if ~strcmp(msg,'label')
ind = findcstr({sigs.label},changedStruc.label);
else % need to search for the signal whose label changed!
ind = [];
for i=1:length(sigs)
temp = sigs(i);
temp.label = changedStruc.label;
if isequal(temp,changedStruc)
ind = i;
break
end
end
end
switch msg
case 'Fs'
for i=linkedSpect
oldFs = spect(i).Fs;
spect(i).Fs = sigs(ind).Fs;
if ~isempty(spect(i).f)
spect(i).f = spect(i).f*spect(i).Fs/oldFs;
end
sptool('import',spect(i),0,SPTfig)
end
case 'label'
for i=linkedSpect
spect(i).signalLabel = sigs(ind).label;
sptool('import',spect(i),0,SPTfig)
end
case 'new'
if ~isequal(sigs(ind).data,changedStruc.data) | ...
~isequal(sigs(ind).Fs,changedStruc.Fs)
for i=linkedSpect
spect(i).signal = [size(sigs(ind).data) ~isreal(sigs(ind).data)];
spect(i).Fs = sigs(ind).Fs;
spect(i).f = [];
spect(i).P = [];
sptool('import',spect(i),0,SPTfig)
end
end
case 'clear'
for i=linkedSpect
spect(i).signal = 'none';
spect(i).signalLabel = '';
sptool('import',spect(i),0,SPTfig)
end
end
spectview('update',fig,spect,spectInd,SPTfig,'new')
%------------------------------------------------------------------------
% spectview('SPTclose',action)
% Spectrum Viewer close request function
% This function is called when a browser window is closed.
% action will be: 'view', 'create' or 'update'
% only closes window on 'view'
% action is optional; will close tool if left off
case 'SPTclose'
if nargin==2
if ~strcmp(varargin{2},'view')
return
end
end
fig = findobj('type','figure','tag','spectview');
if ~isempty(fig)
ud = get(fig,'userdata');
if ~isempty(ud.tabfig)
delete(ud.tabfig)
end
delete(fig)
end
%------------------------------------------------------------------------
% spectview('print')
% print contents of spectview (assumed in gcf)
case 'print'
%shh = get(0,'showhiddenhandles');
%set(0,'showhiddenhandles','on')
%ch = [gcf; findobj(gcf,'type','uicontrol'); findobj(gcf,'type','axes')];
%save_units = get(ch,'units');
%set(ch,'units','points');
%save_resize = get(gcf,'resizefcn');
%set(gcf,'resizefcn','')
%dlg = pagedlg(gcf);
%set(dlg,'windowstyle','modal')
%printdlg(gcf)
%set(gcf,'resizefcn',save_resize);
%set(ch,{'units'},save_units)
%set(0,'showhiddenhandles',shh)
%------------------------------------------------------------------------
% spectview('help')
% Callback of help button in toolbar
case 'help'
fig = gcf;
ud = get(fig,'userdata');
if ud.pointer ~= 2 % if not in help mode
% enter help mode
saveEnableControls = [ud.hand.applyButton
ud.hand.revertButton
ud.hand.confidenceCheckbox
ud.hand.confidenceEdit
ud.hand.methodLabel
ud.hand.methodPopup
ud.hand.inheritPopup
ud.hand.label(:)
ud.hand.uicontrol(:)
ud.legend.legendpopup
ud.legend.legendbutton];
ax = [ud.mainaxes ud.toolbar.toolbar];
if ud.prefs.tool.ruler
ax = [ax ud.ruler.hand.ruleraxes];
end
titleStr = 'Spectrum Viewer Help';
helpFcn = 'sphelpstr';
spthelp('enter',fig,saveEnableControls,ax,titleStr,helpFcn)
else
spthelp('exit')
end
%------------------------------------------------------------------------
% spectview('fillParams',fig,methodName,valueArray,confid)
% set uicontrol values and strings and enable / visible properties
% for parameters.
% Inputs:
% fig - figure handle of spectview tool
% methodName - string; specifies method with which to fill the uicontols
% valueArray - cell array which has the value for each parameter
% (string entry for edit, number for popup or checkbox, cell array for
% subordinate parameters)
% confid - structure; .enable == 1 or 0, .level = string, .Pc (optional)
% is the confidence limits array
case 'fillParams'
fig = varargin{2};
methodName = varargin{3};
valueArray = varargin{4};
confid = varargin{5};
ud = get(fig,'userdata');
methodNameList = {ud.methods.methodName};
methodNum = findcstr(methodNameList,methodName);
set(ud.hand.methodPopup,'value',methodNum)
m = ud.methods(methodNum);
for i=1:length(m.type)
% is this parameter a subordinate? Change it if not:
if isstr(m.type{i})
changeParamType(m.type{i},...
valueArray{i},...
m.label{i},...
m.popupString{i},...
ud.hand.label(i),...
ud.hand.uicontrol(i))
end
end
% set types, strings and values of subordinate uicontrols:
for i=1:length(m.type)
for j = m.subordinates{i}
popupVal = valueArray{i};
if iscell(valueArray{j})
changeParamType(ud.methods(methodNum).type{j}{popupVal},...
valueArray{j}{popupVal},...
ud.methods(methodNum).label{j}{popupVal},...
ud.methods(methodNum).popupString{j}{popupVal},...
ud.hand.label(j),...
ud.hand.uicontrol(j))
else
changeParamType(ud.methods(methodNum).type{j}{popupVal},...
valueArray{j},...
ud.methods(methodNum).label{j}{popupVal},...
ud.methods(methodNum).popupString{j}{popupVal},...
ud.hand.label(j),...
ud.hand.uicontrol(j))
end
end
end
for i=length(m.type)+1:length(ud.hand.uicontrol)
set([ud.hand.label(i) ud.hand.uicontrol(i)],'visible','off')
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -