PageRenderTime 29ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/ATF2/FlightSim/testApps/multiKnobs/multiKnobs_edit.m

http://atf2flightsim.googlecode.com/
MATLAB | 630 lines | 309 code | 97 blank | 224 comment | 55 complexity | c7078a9bccc9326586f3b79ea97de6ab MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. function varargout = multiKnobs_edit(varargin)
  2. % MULTIKNOBS_EDIT M-file for multiKnobs_edit.fig
  3. % MULTIKNOBS_EDIT, by itself, creates a new MULTIKNOBS_EDIT or raises the existing
  4. % singleton*.
  5. %
  6. % H = MULTIKNOBS_EDIT returns the handle to a new MULTIKNOBS_EDIT or the handle to
  7. % the existing singleton*.
  8. %
  9. % MULTIKNOBS_EDIT('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in MULTIKNOBS_EDIT.M with the given input arguments.
  11. %
  12. % MULTIKNOBS_EDIT('Property','Value',...) creates a new MULTIKNOBS_EDIT or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before multiKnobs_edit_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to multiKnobs_edit_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22. % Edit the above text to modify the response to help multiKnobs_edit
  23. % Last Modified by GUIDE v2.5 29-Jun-2009 11:33:19
  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name', mfilename, ...
  27. 'gui_Singleton', gui_Singleton, ...
  28. 'gui_OpeningFcn', @multiKnobs_edit_OpeningFcn, ...
  29. 'gui_OutputFcn', @multiKnobs_edit_OutputFcn, ...
  30. 'gui_LayoutFcn', [] , ...
  31. 'gui_Callback', []);
  32. if nargin && ischar(varargin{1})
  33. gui_State.gui_Callback = str2func(varargin{1});
  34. end
  35. if nargout
  36. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38. gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT
  41. % --- Executes just before multiKnobs_edit is made visible.
  42. function multiKnobs_edit_OpeningFcn(hObject, eventdata, handles, varargin)
  43. % This function has no output args, see OutputFcn.
  44. % hObject handle to figure
  45. % eventdata reserved - to be defined in a future version of MATLAB
  46. % handles structure with handles and user data (see GUIDATA)
  47. % varargin command line arguments to multiKnobs_edit (see VARARGIN)
  48. % Choose default command line output for multiKnobs_edit
  49. handles.output = handles;
  50. % Fill table popupmenu
  51. [stat pars]=multiKnobsFn('GetPars');
  52. set(handles.popupmenu2,'String',pars.tableNames)
  53. % Update handles structure
  54. guidata(hObject, handles);
  55. % UIWAIT makes multiKnobs_edit wait for user response (see UIRESUME)
  56. % uiwait(handles.figure1);
  57. % --- Outputs from this function are returned to the command line.
  58. function varargout = multiKnobs_edit_OutputFcn(hObject, eventdata, handles)
  59. % varargout cell array for returning output args (see VARARGOUT);
  60. % hObject handle to figure
  61. % eventdata reserved - to be defined in a future version of MATLAB
  62. % handles structure with handles and user data (see GUIDATA)
  63. % Get default command line output from handles structure
  64. varargout{1} = handles.output;
  65. % --- Save and Quit
  66. function pushbutton6_Callback(hObject, eventdata, handles)
  67. % hObject handle to pushbutton6 (see GCBO)
  68. % eventdata reserved - to be defined in a future version of MATLAB
  69. % handles structure with handles and user data (see GUIDATA)
  70. global FL
  71. try
  72. if isfield(FL.Gui,'multiKnobs') && ishandle(FL.Gui.multiKnobs.figure1)
  73. [stat pars]=multiKnobsFn('GetPars');
  74. set(FL.Gui.multiKnobs.popupmenu1,'String',pars.knobNames)
  75. wknob=strcmp(get(handles.edit4,'String'),pars.knobNames);
  76. if any(wknob)
  77. set(FL.Gui.multiKnobs.popupmenu1,'Value',find(wknob))
  78. end
  79. end
  80. % Save data to server
  81. sreq_wait;
  82. shan=msgbox('Saving data to server...');
  83. stat=multiKnobsFn('save');
  84. if ishandle(shan); delete(shan); end;
  85. if stat{1}~=1 && length(stat)==2 && iscell(stat)
  86. errordlg(stat{2},'Server save error')
  87. end
  88. sreq_wait('restart')
  89. % if isfield(FL.Gui,'multiKnobs') && ishandle(FL.Gui.multiKnobs.figure1)
  90. % multiKnobs('popupmenu1_Callback',FL.Gui.multiKnobs.popupmenu1,[],FL.Gui.multiKnobs)
  91. % end
  92. guiCloseFn('multiKnobs_edit',handles);
  93. catch
  94. warning(lasterr)
  95. if exist('shan','var') && ishandle(shan); delete(shan); end;
  96. errordlg('Save failed, restart window to retry','save error')
  97. delete(handles.figure1)
  98. end
  99. % --- Cancel knob edit
  100. function pushbutton7_Callback(hObject, eventdata, handles)
  101. % hObject handle to pushbutton7 (see GCBO)
  102. % eventdata reserved - to be defined in a future version of MATLAB
  103. % handles structure with handles and user data (see GUIDATA)
  104. % edit knob name
  105. function edit4_Callback(hObject, eventdata, handles)
  106. % hObject handle to edit4 (see GCBO)
  107. % eventdata reserved - to be defined in a future version of MATLAB
  108. % handles structure with handles and user data (see GUIDATA)
  109. if ~isempty(regexp(get(hObject,'String'),'\W', 'once'))
  110. errordlg('No spaces or symbols allowed in name','Name error')
  111. return
  112. end
  113. % Not allowed names
  114. if any(strcmp(get(hObject,'String'),{'table' 'knobNames' 'lastKnob' 'tableNames'}))
  115. errordlg('This name not allowed- pick another','Name error')
  116. return
  117. end
  118. pushbutton11_Callback(handles.pushbutton11,[],handles);
  119. % --- Executes during object creation, after setting all properties.
  120. function edit4_CreateFcn(hObject, eventdata, handles)
  121. % hObject handle to edit4 (see GCBO)
  122. % eventdata reserved - to be defined in a future version of MATLAB
  123. % handles empty - handles not created until after all CreateFcns called
  124. % Hint: edit controls usually have a white background on Windows.
  125. % See ISPC and COMPUTER.
  126. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  127. set(hObject,'BackgroundColor','white');
  128. end
  129. % --- Executes on button press in radiobutton2.
  130. function radiobutton2_Callback(hObject, eventdata, handles)
  131. % hObject handle to radiobutton2 (see GCBO)
  132. % eventdata reserved - to be defined in a future version of MATLAB
  133. % handles structure with handles and user data (see GUIDATA)
  134. % Hint: get(hObject,'Value') returns toggle state of radiobutton2
  135. % --- Executes on selection change in popupmenu1.
  136. function popupmenu1_Callback(hObject, eventdata, handles)
  137. % hObject handle to popupmenu1 (see GCBO)
  138. % eventdata reserved - to be defined in a future version of MATLAB
  139. % handles structure with handles and user data (see GUIDATA)
  140. % Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
  141. % contents{get(hObject,'Value')} returns selected item from popupmenu1
  142. % --- Executes during object creation, after setting all properties.
  143. function popupmenu1_CreateFcn(hObject, eventdata, handles)
  144. % hObject handle to popupmenu1 (see GCBO)
  145. % eventdata reserved - to be defined in a future version of MATLAB
  146. % handles empty - handles not created until after all CreateFcns called
  147. % Hint: popupmenu controls usually have a white background on Windows.
  148. % See ISPC and COMPUTER.
  149. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  150. set(hObject,'BackgroundColor','white');
  151. end
  152. function edit1_Callback(hObject, eventdata, handles)
  153. % hObject handle to edit1 (see GCBO)
  154. % eventdata reserved - to be defined in a future version of MATLAB
  155. % handles structure with handles and user data (see GUIDATA)
  156. % Hints: get(hObject,'String') returns contents of edit1 as text
  157. % str2double(get(hObject,'String')) returns contents of edit1 as a double
  158. if isnan(str2double(get(hObject,'String')))
  159. errordlg('Bad input for Type Index','Multiknob edit error')
  160. set(hObject,'String',[])
  161. guidata(hObject, handles);
  162. end
  163. % --- Executes during object creation, after setting all properties.
  164. function edit1_CreateFcn(hObject, eventdata, handles)
  165. % hObject handle to edit1 (see GCBO)
  166. % eventdata reserved - to be defined in a future version of MATLAB
  167. % handles empty - handles not created until after all CreateFcns called
  168. % Hint: edit controls usually have a white background on Windows.
  169. % See ISPC and COMPUTER.
  170. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  171. set(hObject,'BackgroundColor','white');
  172. end
  173. % --- Get index from viewer
  174. function pushbutton4_Callback(hObject, eventdata, handles)
  175. % hObject handle to pushbutton4 (see GCBO)
  176. % eventdata reserved - to be defined in a future version of MATLAB
  177. % handles structure with handles and user data (see GUIDATA)
  178. global FL BEAMLINE GIRDER
  179. ktype=get(handles.popupmenu1,'String');
  180. % Launch viewer if not already there
  181. if ~isfield(FL.Gui,'BeamlineViewer') ||~isfield(FL.Gui.BeamlineViewer,'figure1') || ~ishandle(FL.Gui.BeamlineViewer.figure1)
  182. FL.Gui.BeamlineViewer=BeamlineViewer;
  183. else
  184. bl=get(FL.Gui.BeamlineViewer.listbox1,'String');
  185. wbl=get(FL.Gui.BeamlineViewer.listbox1,'Value');
  186. ibl=str2double(regexp(bl{wbl(1)},'^\d+','match'));
  187. wk=ktype{get(handles.popupmenu1,'Value')};
  188. if strcmp(wk,'GIRDER')
  189. wk='Girder';
  190. if ~isfield(GIRDER{BEAMLINE{ibl}.(wk)},'Mover')
  191. errordlg('No Mover on this girder','Add Control Error')
  192. return
  193. end
  194. end
  195. if isfield(BEAMLINE{ibl},wk)
  196. set(handles.edit1,'String',num2str(BEAMLINE{ibl}.(wk)))
  197. else
  198. errordlg(['No ',ktype{get(handles.popupmenu1,'Value')},' field for this element'],'BeamlineViewer Select Error')
  199. set(handles.edit1,'String','')
  200. end
  201. end
  202. function edit2_Callback(hObject, eventdata, handles)
  203. % hObject handle to edit2 (see GCBO)
  204. % eventdata reserved - to be defined in a future version of MATLAB
  205. % handles structure with handles and user data (see GUIDATA)
  206. % Hints: get(hObject,'String') returns contents of edit2 as text
  207. % str2double(get(hObject,'String')) returns contents of edit2 as a double
  208. % --- Executes during object creation, after setting all properties.
  209. function edit2_CreateFcn(hObject, eventdata, handles)
  210. % hObject handle to edit2 (see GCBO)
  211. % eventdata reserved - to be defined in a future version of MATLAB
  212. % handles empty - handles not created until after all CreateFcns called
  213. % Hint: edit controls usually have a white background on Windows.
  214. % See ISPC and COMPUTER.
  215. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  216. set(hObject,'BackgroundColor','white');
  217. end
  218. function edit3_Callback(hObject, eventdata, handles)
  219. % hObject handle to edit3 (see GCBO)
  220. % eventdata reserved - to be defined in a future version of MATLAB
  221. % handles structure with handles and user data (see GUIDATA)
  222. % Hints: get(hObject,'String') returns contents of edit3 as text
  223. % str2double(get(hObject,'String')) returns contents of edit3 as a double
  224. % --- Executes during object creation, after setting all properties.
  225. function edit3_CreateFcn(hObject, eventdata, handles)
  226. % hObject handle to edit3 (see GCBO)
  227. % eventdata reserved - to be defined in a future version of MATLAB
  228. % handles empty - handles not created until after all CreateFcns called
  229. % Hint: edit controls usually have a white background on Windows.
  230. % See ISPC and COMPUTER.
  231. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  232. set(hObject,'BackgroundColor','white');
  233. end
  234. % --- Executes on button press in pushbutton5.
  235. function pushbutton5_Callback(hObject, eventdata, handles)
  236. % hObject handle to pushbutton5 (see GCBO)
  237. % eventdata reserved - to be defined in a future version of MATLAB
  238. % handles structure with handles and user data (see GUIDATA)
  239. % --- New table
  240. function pushbutton3_Callback(hObject, eventdata, handles)
  241. % hObject handle to pushbutton3 (see GCBO)
  242. % eventdata reserved - to be defined in a future version of MATLAB
  243. % handles structure with handles and user data (see GUIDATA)
  244. global FL
  245. FL.Gui.multiKnobs_table=multiKnobs_table;
  246. % --- Executes on button press in radiobutton1.
  247. function radiobutton1_Callback(hObject, eventdata, handles)
  248. % hObject handle to radiobutton1 (see GCBO)
  249. % eventdata reserved - to be defined in a future version of MATLAB
  250. % handles structure with handles and user data (see GUIDATA)
  251. if get(hObject,'Value')
  252. set(handles.radiobutton3,'Value',0)
  253. else
  254. set(handles.radiobutton3,'Value',1)
  255. end
  256. % --- Executes on selection change in Knob Control list
  257. function listbox1_Callback(hObject, eventdata, handles)
  258. % hObject handle to listbox1 (see GCBO)
  259. % eventdata reserved - to be defined in a future version of MATLAB
  260. % handles structure with handles and user data (see GUIDATA)
  261. [stat pars]=multiKnobsFn('GetPars');
  262. thisKnobName=get(handles.edit4,'String');
  263. if ~any(strcmp(thisKnobName,pars.knobNames))
  264. return
  265. end
  266. ic=get(hObject,'Value');
  267. klist=get(hObject,'String');
  268. if strcmp(klist{ic},'<none>')
  269. return
  270. end
  271. if strcmp(pars.(thisKnobName).control(ic).method,'table')
  272. set(handles.radiobutton1,'Value',1); set(handles.radiobutton3,'Value',0)
  273. tnames=get(handles.popupmenu2,'String');
  274. wt=find(strcmp(pars.(thisKnobName).control(ic).table,tnames));
  275. if isempty(wt)
  276. errordlg('This table name no longer exists','Table error')
  277. return
  278. end
  279. set(handles.popupmenu2,'Value',wt);
  280. else
  281. set(handles.radiobutton1,'Value',0); set(handles.radiobutton3,'Value',1)
  282. set(handles.edit5,'String',num2str(pars.(thisKnobName).control(ic).exponent))
  283. set(handles.edit6,'String',num2str(pars.(thisKnobName).control(ic).scale))
  284. end
  285. if strcmp(pars.(thisKnobName).control(ic).type,'PS')
  286. set(handles.popupmenu1,'Value',1)
  287. elseif strcmp(pars.(thisKnobName).control(ic).type,'GIRDER')
  288. set(handles.popupmenu1,'Value',2)
  289. end
  290. set(handles.edit1,'String',num2str(pars.(thisKnobName).control(ic).index))
  291. % --- Executes during object creation, after setting all properties.
  292. function listbox1_CreateFcn(hObject, eventdata, handles)
  293. % hObject handle to listbox1 (see GCBO)
  294. % eventdata reserved - to be defined in a future version of MATLAB
  295. % handles empty - handles not created until after all CreateFcns called
  296. % Hint: listbox controls usually have a white background on Windows.
  297. % See ISPC and COMPUTER.
  298. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  299. set(hObject,'BackgroundColor','white');
  300. end
  301. % --- Delete control entry
  302. function pushbutton2_Callback(hObject, eventdata, handles)
  303. % hObject handle to pushbutton2 (see GCBO)
  304. % eventdata reserved - to be defined in a future version of MATLAB
  305. % handles structure with handles and user data (see GUIDATA)
  306. klist=get(handles.listbox1,'String');
  307. ic=get(handles.listbox1,'Value');
  308. if length(klist)<2
  309. errordlg('Cannot delete all controls','Control delete error')
  310. return
  311. end
  312. stat=multiKnobsFn('DeleteControl',get(handles.edit4,'String'),ic);
  313. if stat{1}~=1
  314. errordlg(stat{2},'Control delete error')
  315. return
  316. end
  317. pushbutton11_Callback(handles.pushbutton11,[],handles);
  318. % --- Executes on button press in radiobutton3.
  319. function radiobutton3_Callback(hObject, eventdata, handles)
  320. % hObject handle to radiobutton3 (see GCBO)
  321. % eventdata reserved - to be defined in a future version of MATLAB
  322. % handles structure with handles and user data (see GUIDATA)
  323. % Hint: get(hObject,'Value') returns toggle state of radiobutton3
  324. if get(hObject,'Value')
  325. set(handles.radiobutton1,'Value',0)
  326. else
  327. set(handles.radiobutton1,'Value',1)
  328. end
  329. function edit5_Callback(hObject, eventdata, handles)
  330. % hObject handle to edit5 (see GCBO)
  331. % eventdata reserved - to be defined in a future version of MATLAB
  332. % handles structure with handles and user data (see GUIDATA)
  333. % Hints: get(hObject,'String') returns contents of edit5 as text
  334. % str2double(get(hObject,'String')) returns contents of edit5 as a double
  335. if isnan(str2double(get(hObject,'String')))
  336. errordlg('Bad input for Type Index','Multiknob edit error')
  337. set(hObject,'String',[])
  338. guidata(hObject, handles);
  339. end
  340. % --- Executes during object creation, after setting all properties.
  341. function edit5_CreateFcn(hObject, eventdata, handles)
  342. % hObject handle to edit5 (see GCBO)
  343. % eventdata reserved - to be defined in a future version of MATLAB
  344. % handles empty - handles not created until after all CreateFcns called
  345. % Hint: edit controls usually have a white background on Windows.
  346. % See ISPC and COMPUTER.
  347. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  348. set(hObject,'BackgroundColor','white');
  349. end
  350. function edit6_Callback(hObject, eventdata, handles)
  351. % hObject handle to edit6 (see GCBO)
  352. % eventdata reserved - to be defined in a future version of MATLAB
  353. % handles structure with handles and user data (see GUIDATA)
  354. % Hints: get(hObject,'String') returns contents of edit6 as text
  355. % str2double(get(hObject,'String')) returns contents of edit6 as a double
  356. if isnan(str2double(get(hObject,'String')))
  357. errordlg('Bad input for Type Index','Multiknob edit error')
  358. set(hObject,'String',[])
  359. guidata(hObject, handles);
  360. end
  361. % --- Executes during object creation, after setting all properties.
  362. function edit6_CreateFcn(hObject, eventdata, handles)
  363. % hObject handle to edit6 (see GCBO)
  364. % eventdata reserved - to be defined in a future version of MATLAB
  365. % handles empty - handles not created until after all CreateFcns called
  366. % Hint: edit controls usually have a white background on Windows.
  367. % See ISPC and COMPUTER.
  368. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  369. set(hObject,'BackgroundColor','white');
  370. end
  371. % --- Executes on selection change in popupmenu2.
  372. function popupmenu2_Callback(hObject, eventdata, handles)
  373. % hObject handle to popupmenu2 (see GCBO)
  374. % eventdata reserved - to be defined in a future version of MATLAB
  375. % handles structure with handles and user data (see GUIDATA)
  376. % Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
  377. % contents{get(hObject,'Value')} returns selected item from popupmenu2
  378. % --- Executes during object creation, after setting all properties.
  379. function popupmenu2_CreateFcn(hObject, eventdata, handles)
  380. % hObject handle to popupmenu2 (see GCBO)
  381. % eventdata reserved - to be defined in a future version of MATLAB
  382. % handles empty - handles not created until after all CreateFcns called
  383. % Hint: popupmenu controls usually have a white background on Windows.
  384. % See ISPC and COMPUTER.
  385. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  386. set(hObject,'BackgroundColor','white');
  387. end
  388. % --- Edit table
  389. function pushbutton8_Callback(hObject, eventdata, handles)
  390. % hObject handle to pushbutton8 (see GCBO)
  391. % eventdata reserved - to be defined in a future version of MATLAB
  392. % handles structure with handles and user data (see GUIDATA)
  393. global FL
  394. klist=get(handles.popupmenu2,'String');
  395. FL.Gui.multiKnobs_table=multiKnobs_table;
  396. set(FL.Gui.multiKnobs_table.edit1,'String',klist{get(handles.popupmenu2,'Value')})
  397. multiKnobs_table('edit1_Callback',FL.Gui.multiKnobs_table.edit1,[],FL.Gui.multiKnobs_table)
  398. % --- Add new control
  399. function pushbutton9_Callback(hObject, eventdata, handles)
  400. % hObject handle to pushbutton9 (see GCBO)
  401. % eventdata reserved - to be defined in a future version of MATLAB
  402. % handles structure with handles and user data (see GUIDATA)
  403. global GIRDER
  404. typeList=get(handles.popupmenu1,'String');
  405. controlStruc.type=typeList{get(handles.popupmenu1,'Value')};
  406. controlStruc.index=str2double(get(handles.edit1,'String'));
  407. if strcmp(controlStruc.type,'GIRDER') && ~isfield(GIRDER{controlStruc.index},'Mover')
  408. errordlg('No Mover for this girder','Add control error')
  409. return
  410. end
  411. controlStruc.dof=get(handles.popupmenu3,'Value');
  412. if get(handles.radiobutton1,'Value')
  413. controlStruc.method='table';
  414. tableList=get(handles.popupmenu2,'String');
  415. controlStruc.table=tableList{get(handles.popupmenu2,'Value')};
  416. else
  417. controlStruc.method='expScale';
  418. controlStruc.exponent=str2double(get(handles.edit5,'String'));
  419. controlStruc.scale=str2double(get(handles.edit6,'String'));
  420. end
  421. stat=multiKnobsFn('MakeControl',get(handles.edit4,'String'),controlStruc);
  422. if stat{1}~=1
  423. errordlg(stat{2},'Make control error')
  424. return
  425. end
  426. pushbutton11_Callback(handles.pushbutton11,[],handles);
  427. % --- delete knob
  428. function pushbutton10_Callback(hObject, eventdata, handles) %#ok<*INUSD>
  429. % hObject handle to pushbutton10 (see GCBO)
  430. % eventdata reserved - to be defined in a future version of MATLAB
  431. % handles structure with handles and user data (see GUIDATA)
  432. if ~strcmp(questdlg('Delete this knob?','Knob deletion request'),'Yes')
  433. return
  434. end
  435. [stat pars]=multiKnobsFn('GetPars');
  436. knobName=get(handles.edit4,'String');
  437. if strcmp(knobName,'Default')
  438. errordlg('Cannot delete default knob','Knob delete error')
  439. return
  440. end
  441. if ~any(strcmp(knobName,pars.knobNames))
  442. errordlg('No store knob names found which match this','Knob delete error')
  443. return
  444. end
  445. stat=multiKnobsFn('Delete',knobName);
  446. if stat{1}~=1; errordlg(stat{2},'Knob delete error'); return; end;
  447. set(handles.edit4,'String','NewKnob');
  448. pushbutton11_Callback(handles.pushbutton11,[],handles);
  449. if isfield(FL.Gui,'multiKnobs') && ishandle(FL.Gui.multiKnobs.figure1)
  450. [stat pars]=multiKnobsFn('GetPars');
  451. set(FL.Gui.multiKnobs.popupmenu1,'Value',1)
  452. set(FL.Gui.multiKnobs.popupmenu1,'String',pars.knobNames)
  453. multiKnobs('popupmenu1_Callback',FL.Gui.multiKnobs.popupmenu1,[],FL.Gui.multiKnobs)
  454. end
  455. % --- Reset Knob Settings
  456. function pushbutton11_Callback(hObject, eventdata, handles) %#ok<*INUSL,*DEFNU>
  457. % hObject handle to pushbutton11 (see GCBO)
  458. % eventdata reserved - to be defined in a future version of MATLAB
  459. % handles structure with handles and user data (see GUIDATA)
  460. if isempty(get(handles.edit4,'String'))
  461. set(handles.edit4,'String','Default')
  462. end
  463. if ~isempty(regexp(get(handles.edit4,'String'),'\W', 'once'))
  464. errordlg('No spaces or symbols allowed in name')
  465. return
  466. end
  467. % Get list of knob names
  468. [stat pars]=multiKnobsFn('GetPars');
  469. thisKnobName=get(handles.edit4,'String');
  470. % If user defined knob, shouldn't be editing here
  471. if exist(['userMK_',thisKnobName],'file')
  472. errordlg('This knob is classified as a user defined knob and has an associated m file that should be used for editing, not this panel','Knob Error')
  473. return
  474. end
  475. % If knob already exists, fill GUI fields
  476. if any(strcmp(thisKnobName,pars.knobNames))
  477. set(handles.listbox1,'String',pars.(thisKnobName).knobControls_txt)
  478. set(handles.listbox1,'Value',1)
  479. listbox1_Callback(handles.listbox1,[],handles)
  480. else
  481. set(handles.listbox1,'String','<none>')
  482. set(handles.listbox1,'Value',1)
  483. end
  484. % --- Executes when user attempts to close figure1.
  485. function figure1_CloseRequestFcn(hObject, eventdata, handles)
  486. % hObject handle to figure1 (see GCBO)
  487. % eventdata reserved - to be defined in a future version of MATLAB
  488. % handles structure with handles and user data (see GUIDATA)
  489. global FL
  490. try
  491. if isfield(FL.Gui,'multiKnobs') && ishandle(FL.Gui.multiKnobs)
  492. [stat pars]=multiKnobsFn('GetPars');
  493. set(FL.Gui.multiKnobs.popupmenu1,'String',pars.knobNames)
  494. wknob=strcmp(get(handles.edit4,'String'),pars.knobNames);
  495. if any(wknob)
  496. set(FL.Gui.multiKnobs.popupmenu1,'Value',find(wknob))
  497. end
  498. end
  499. % Save data to server
  500. shan=msgbox('Saving data to server...');
  501. stat=multiKnobsFn('save');
  502. if ishandle(shan); delete(shan); end;
  503. if stat{1}~=1
  504. errordlg(stat{2},'Server save error')
  505. end
  506. guiCloseFn('multiKnobs_edit',handles);
  507. catch
  508. warning(lasterr)
  509. if exist('shan','var') && ishandle(shan); delete(shan); end;
  510. delete(handles.figure1)
  511. end
  512. % --- Executes on selection change in popupmenu3.
  513. function popupmenu3_Callback(hObject, eventdata, handles)
  514. % hObject handle to popupmenu3 (see GCBO)
  515. % eventdata reserved - to be defined in a future version of MATLAB
  516. % handles structure with handles and user data (see GUIDATA)
  517. % Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array
  518. % contents{get(hObject,'Value')} returns selected item from popupmenu3
  519. % --- Executes during object creation, after setting all properties.
  520. function popupmenu3_CreateFcn(hObject, eventdata, handles)
  521. % hObject handle to popupmenu3 (see GCBO)
  522. % eventdata reserved - to be defined in a future version of MATLAB
  523. % handles empty - handles not created until after all CreateFcns called
  524. % Hint: popupmenu controls usually have a white background on Windows.
  525. % See ISPC and COMPUTER.
  526. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  527. set(hObject,'BackgroundColor','white');
  528. end
  529. % --- Executes during object creation, after setting all properties.
  530. function figure1_CreateFcn(hObject, eventdata, handles)
  531. % hObject handle to figure1 (see GCBO)
  532. % eventdata reserved - to be defined in a future version of MATLAB
  533. % handles empty - handles not created until after all CreateFcns called