PageRenderTime 29ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/matlab/src/PCOCAM/SetCam.m

http://matlabdb.googlecode.com/
MATLAB | 992 lines | 492 code | 144 blank | 356 comment | 104 complexity | ed99838182b767df74d59d12f406bce0 MD5 | raw file
  1. function varargout = SetCam(varargin)
  2. % SETCAM M-file for SetCam.fig
  3. % SETCAM, by itself, creates a new SETCAM or raises the existing
  4. % singleton*.
  5. %
  6. % H = SETCAM returns the handle to a new SETCAM or the handle to
  7. % the existing singleton*.
  8. %
  9. % SETCAM('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in SETCAM.M with the given input arguments.
  11. %
  12. % SETCAM('Property','Value',...) creates a new SETCAM or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before SetCam_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to SetCam_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 SetCam
  23. % Last Modified by GUIDE v2.5 02-Jan-2011 18:22:52
  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', @SetCam_OpeningFcn, ...
  29. 'gui_OutputFcn', @SetCam_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 SetCam is made visible.
  42. function SetCam_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 SetCam (see VARARGIN)
  48. % Choose default command line output for SetCam
  49. % handles.output = hObject;
  50. axis(handles.roi_view,[0,2048,0,2048])
  51. axis ij ;
  52. str = which('SetCam');str=str(1:end-2);
  53. filename=[str,'config.mat'];
  54. if exist(filename,'file')
  55. load(filename);
  56. handles.output=output;% load from setcamconfig
  57. Self_SetupCombines(handles,output);
  58. if isfield(output,'roi_hori_min')
  59. rectangle('Position',[output.roi_hori_min,output.roi_vert_min,(output.roi_hori_max-output.roi_hori_min),(output.roi_vert_max-output.roi_vert_min)]);
  60. end
  61. else
  62. handles.output=[];
  63. end
  64. handles.XLM = get(handles.roi_view,'xlim');
  65. handles.YLM = get(handles.roi_view,'ylim');
  66. handles.AXP=get(handles.roi_view,'pos');
  67. handles.last=0;
  68. handles.drawrect=0;
  69. guidata(hObject, handles);
  70. % UIWAIT makes SetCam wait for user response (see UIRESUME)
  71. uiwait(handles.ROI);
  72. % --- Outputs from this function are returned to the command line.
  73. function varargout = SetCam_OutputFcn(hObject, eventdata, handles)
  74. % varargout cell array for returning output args (see VARARGOUT);
  75. % hObject handle to figure
  76. % eventdata reserved - to be defined in a future version of MATLAB
  77. % handles structure with handles and user data (see GUIDATA)
  78. % Get default command line output from handles structure
  79. output=handles.output;
  80. output=Self_GetEditValue(handles,output);
  81. str = which('SetCam');str=str(1:end-2);
  82. save([str,'config.mat'],'output');
  83. varargout{1} = output;
  84. delete(hObject);
  85. % --- Executes on selection change in trigmode.
  86. function trigmode_Callback(hObject, eventdata, handles)
  87. % hObject handle to trigmode (see GCBO)
  88. % eventdata reserved - to be defined in a future version of MATLAB
  89. % handles structure with handles and user data (see GUIDATA)
  90. val=get(hObject,'Value');
  91. switch (val)
  92. case 1
  93. handles.output.trigmode=1;
  94. case 2
  95. handles.output.trigmode=2;
  96. case 3
  97. handles.output.trigmode=3;
  98. case 4
  99. handles.output.trigmode=4;
  100. end
  101. guidata(hObject,handles);
  102. % Hints: contents = get(hObject,'String') returns trigmode contents as cell array
  103. % contents{get(hObject,'Value')} returns selected item from trigmode
  104. % --- Executes during object creation, after setting all properties.
  105. function trigmode_CreateFcn(hObject, eventdata, handles)
  106. % hObject handle to trigmode (see GCBO)
  107. % eventdata reserved - to be defined in a future version of MATLAB
  108. % handles empty - handles not created until after all CreateFcns called
  109. % Hint: popupmenu controls usually have a white background on Windows.
  110. % See ISPC and COMPUTER.
  111. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  112. set(hObject,'BackgroundColor','white');
  113. end
  114. function exposure_Callback(hObject, eventdata, handles)
  115. % hObject handle to exposure (see GCBO)
  116. % eventdata reserved - to be defined in a future version of MATLAB
  117. % handles structure with handles and user data (see GUIDATA)
  118. % Hints: get(hObject,'String') returns contents of exposure as text
  119. % str2double(get(hObject,'String')) returns contents of exposure as a double
  120. % --- Executes during object creation, after setting all properties.
  121. function exposure_CreateFcn(hObject, eventdata, handles)
  122. % hObject handle to exposure (see GCBO)
  123. % eventdata reserved - to be defined in a future version of MATLAB
  124. % handles empty - handles not created until after all CreateFcns called
  125. % Hint: edit controls usually have a white background on Windows.
  126. % See ISPC and COMPUTER.
  127. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  128. set(hObject,'BackgroundColor','white');
  129. end
  130. function delay_Callback(hObject, eventdata, handles)
  131. % hObject handle to delay (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. % Hints: get(hObject,'String') returns contents of delay as text
  135. % str2double(get(hObject,'String')) returns contents of delay as a double
  136. % --- Executes during object creation, after setting all properties.
  137. function delay_CreateFcn(hObject, eventdata, handles)
  138. % hObject handle to delay (see GCBO)
  139. % eventdata reserved - to be defined in a future version of MATLAB
  140. % handles empty - handles not created until after all CreateFcns called
  141. % Hint: edit controls usually have a white background on Windows.
  142. % See ISPC and COMPUTER.
  143. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  144. set(hObject,'BackgroundColor','white');
  145. end
  146. % --- Executes on selection change in bin_horizon.
  147. function bin_horizon_Callback(hObject, eventdata, handles)
  148. % hObject handle to bin_horizon (see GCBO)
  149. % eventdata reserved - to be defined in a future version of MATLAB
  150. % handles structure with handles and user data (see GUIDATA)
  151. val=get(hObject,'Value');
  152. switch (val)
  153. case 1
  154. handles.output.bin_horizon=1;
  155. case 2
  156. handles.output.bin_horizon=2;
  157. end
  158. guidata(hObject,handles);
  159. % Hints: contents = get(hObject,'String') returns bin_horizon contents as cell array
  160. % contents{get(hObject,'Value')} returns selected item from bin_horizon
  161. % --- Executes during object creation, after setting all properties.
  162. function bin_horizon_CreateFcn(hObject, eventdata, handles)
  163. % hObject handle to bin_horizon (see GCBO)
  164. % eventdata reserved - to be defined in a future version of MATLAB
  165. % handles empty - handles not created until after all CreateFcns called
  166. % Hint: popupmenu controls usually have a white background on Windows.
  167. % See ISPC and COMPUTER.
  168. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  169. set(hObject,'BackgroundColor','white');
  170. end
  171. % --- Executes on selection change in bin_vertical.
  172. function bin_vertical_Callback(hObject, eventdata, handles)
  173. % hObject handle to bin_vertical (see GCBO)
  174. % eventdata reserved - to be defined in a future version of MATLAB
  175. % handles structure with handles and user data (see GUIDATA)
  176. val=get(hObject,'Value');
  177. switch (val)
  178. case 1
  179. handles.output.bin_vertical=1;
  180. case 2
  181. handles.output.bin_vertical=2;
  182. case 3
  183. handles.output.bin_vertical=3;
  184. case 4
  185. handles.output.bin_vertical=4;
  186. end
  187. guidata(hObject,handles);
  188. % Hints: contents = get(hObject,'String') returns bin_vertical contents as cell array
  189. % contents{get(hObject,'Value')} returns selected item from bin_vertical
  190. % --- Executes during object creation, after setting all properties.
  191. function bin_vertical_CreateFcn(hObject, eventdata, handles)
  192. % hObject handle to bin_vertical (see GCBO)
  193. % eventdata reserved - to be defined in a future version of MATLAB
  194. % handles empty - handles not created until after all CreateFcns called
  195. % Hint: popupmenu controls usually have a white background on Windows.
  196. % See ISPC and COMPUTER.
  197. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  198. set(hObject,'BackgroundColor','white');
  199. end
  200. % --- Executes on selection change in recordmode.
  201. function recordmode_Callback(hObject, eventdata, handles)
  202. % hObject handle to recordmode (see GCBO)
  203. % eventdata reserved - to be defined in a future version of MATLAB
  204. % handles structure with handles and user data (see GUIDATA)
  205. val=get(hObject,'Value');
  206. switch (val)
  207. case 1
  208. handles.output.recordmode=1;
  209. case 2
  210. handles.output.recordmode=2;
  211. end
  212. guidata(hObject,handles);
  213. % Hints: contents = get(hObject,'String') returns recordmode contents as cell array
  214. % contents{get(hObject,'Value')} returns selected item from recordmode
  215. % --- Executes during object creation, after setting all properties.
  216. function recordmode_CreateFcn(hObject, eventdata, handles)
  217. % hObject handle to recordmode (see GCBO)
  218. % eventdata reserved - to be defined in a future version of MATLAB
  219. % handles empty - handles not created until after all CreateFcns called
  220. % Hint: popupmenu controls usually have a white background on Windows.
  221. % See ISPC and COMPUTER.
  222. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  223. set(hObject,'BackgroundColor','white');
  224. end
  225. % --- Executes on selection change in acquiremode.
  226. function acquiremode_Callback(hObject, eventdata, handles)
  227. % hObject handle to acquiremode (see GCBO)
  228. % eventdata reserved - to be defined in a future version of MATLAB
  229. % handles structure with handles and user data (see GUIDATA)
  230. val=get(hObject,'Value');
  231. switch (val)
  232. case 1
  233. handles.output.acquiremode=1;
  234. case 2
  235. handles.output.acquiremode=2;
  236. end
  237. guidata(hObject,handles);
  238. % Hints: contents = get(hObject,'String') returns acquiremode contents as cell array
  239. % contents{get(hObject,'Value')} returns selected item from acquiremode
  240. % --- Executes during object creation, after setting all properties.
  241. function acquiremode_CreateFcn(hObject, eventdata, handles)
  242. % hObject handle to acquiremode (see GCBO)
  243. % eventdata reserved - to be defined in a future version of MATLAB
  244. % handles empty - handles not created until after all CreateFcns called
  245. % Hint: popupmenu controls usually have a white background on Windows.
  246. % See ISPC and COMPUTER.
  247. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  248. set(hObject,'BackgroundColor','white');
  249. end
  250. % --- Executes on selection change in timestamp.
  251. function timestamp_Callback(hObject, eventdata, handles)
  252. % hObject handle to timestamp (see GCBO)
  253. % eventdata reserved - to be defined in a future version of MATLAB
  254. % handles structure with handles and user data (see GUIDATA)
  255. val=get(hObject,'Value');
  256. switch (val)
  257. case 1
  258. handles.output.timestamp=1;
  259. case 2
  260. handles.output.timestamp=2;
  261. case 3
  262. handles.output.timestamp=3;
  263. case 4
  264. handles.output.timestamp=4;
  265. end
  266. guidata(hObject,handles);
  267. % Hints: contents = get(hObject,'String') returns timestamp contents as cell array
  268. % contents{get(hObject,'Value')} returns selected item from timestamp
  269. % --- Executes during object creation, after setting all properties.
  270. function timestamp_CreateFcn(hObject, eventdata, handles)
  271. % hObject handle to timestamp (see GCBO)
  272. % eventdata reserved - to be defined in a future version of MATLAB
  273. % handles empty - handles not created until after all CreateFcns called
  274. % Hint: popupmenu controls usually have a white background on Windows.
  275. % See ISPC and COMPUTER.
  276. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  277. set(hObject,'BackgroundColor','white');
  278. end
  279. % --- Executes on selection change in adconverter.
  280. function adconverter_Callback(hObject, eventdata, handles)
  281. % hObject handle to adconverter (see GCBO)
  282. % eventdata reserved - to be defined in a future version of MATLAB
  283. % handles structure with handles and user data (see GUIDATA)
  284. val=get(hObject,'Value');
  285. switch (val)
  286. case 1
  287. handles.output.adconverter=1;
  288. case 2
  289. handles.output.adconverter=2;
  290. end
  291. guidata(hObject,handles);
  292. % Hints: contents = get(hObject,'String') returns adconverter contents as cell array
  293. % contents{get(hObject,'Value')} returns selected item from adconverter
  294. % --- Executes during object creation, after setting all properties.
  295. function adconverter_CreateFcn(hObject, eventdata, handles)
  296. % hObject handle to adconverter (see GCBO)
  297. % eventdata reserved - to be defined in a future version of MATLAB
  298. % handles empty - handles not created until after all CreateFcns called
  299. % Hint: popupmenu controls usually have a white background on Windows.
  300. % See ISPC and COMPUTER.
  301. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  302. set(hObject,'BackgroundColor','white');
  303. end
  304. % --- Executes on selection change in pixelclock.
  305. function pixelclock_Callback(hObject, eventdata, handles)
  306. % hObject handle to pixelclock (see GCBO)
  307. % eventdata reserved - to be defined in a future version of MATLAB
  308. % handles structure with handles and user data (see GUIDATA)
  309. val=get(hObject,'Value');
  310. switch (val)
  311. case 1
  312. handles.output.pixelclock=1;
  313. case 2
  314. handles.output.pixelclock=2;
  315. end
  316. guidata(hObject,handles);
  317. % Hints: contents = get(hObject,'String') returns pixelclock contents as cell array
  318. % contents{get(hObject,'Value')} returns selected item from pixelclock
  319. % --- Executes during object creation, after setting all properties.
  320. function pixelclock_CreateFcn(hObject, eventdata, handles)
  321. % hObject handle to pixelclock (see GCBO)
  322. % eventdata reserved - to be defined in a future version of MATLAB
  323. % handles empty - handles not created until after all CreateFcns called
  324. % Hint: popupmenu controls usually have a white background on Windows.
  325. % See ISPC and COMPUTER.
  326. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  327. set(hObject,'BackgroundColor','white');
  328. end
  329. % % --- Executes on selection change in popupmenu11.
  330. % function popupmenu11_Callback(hObject, eventdata, handles)
  331. % % hObject handle to popupmenu11 (see GCBO)
  332. % % eventdata reserved - to be defined in a future version of MATLAB
  333. % % handles structure with handles and user data (see GUIDATA)
  334. %
  335. % % Hints: contents = get(hObject,'String') returns popupmenu11 contents as cell array
  336. % % contents{get(hObject,'Value')} returns selected item from popupmenu11
  337. %
  338. %
  339. % % --- Executes during object creation, after setting all properties.
  340. % function popupmenu11_CreateFcn(hObject, eventdata, handles)
  341. % % hObject handle to popupmenu11 (see GCBO)
  342. % % eventdata reserved - to be defined in a future version of MATLAB
  343. % % handles empty - handles not created until after all CreateFcns called
  344. %
  345. % % Hint: popupmenu 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. % --- Executes on selection change in doubleimage.
  351. function doubleimage_Callback(hObject, eventdata, handles)
  352. % hObject handle to doubleimage (see GCBO)
  353. % eventdata reserved - to be defined in a future version of MATLAB
  354. % handles structure with handles and user data (see GUIDATA)
  355. val=get(hObject,'Value');
  356. switch (val)
  357. case 1
  358. handles.output.doubleimage=1;
  359. case 2
  360. handles.output.doubleimage=2;
  361. end
  362. guidata(hObject,handles);
  363. % Hints: contents = get(hObject,'String') returns doubleimage contents as cell array
  364. % contents{get(hObject,'Value')} returns selected item from doubleimage
  365. % --- Executes during object creation, after setting all properties.
  366. function doubleimage_CreateFcn(hObject, eventdata, handles)
  367. % hObject handle to doubleimage (see GCBO)
  368. % eventdata reserved - to be defined in a future version of MATLAB
  369. % handles empty - handles not created until after all CreateFcns called
  370. % Hint: popupmenu controls usually have a white background on Windows.
  371. % See ISPC and COMPUTER.
  372. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  373. set(hObject,'BackgroundColor','white');
  374. end
  375. % --- Executes on selection change in bwnoise.
  376. function bwnoise_Callback(hObject, eventdata, handles)
  377. % hObject handle to bwnoise (see GCBO)
  378. % eventdata reserved - to be defined in a future version of MATLAB
  379. % handles structure with handles and user data (see GUIDATA)
  380. val=get(hObject,'Value');
  381. switch (val)
  382. case 1
  383. handles.output.bwnoise=1;
  384. case 2
  385. handles.output.bwnoise=2;
  386. end
  387. guidata(hObject,handles);
  388. % Hints: contents = get(hObject,'String') returns bwnoise contents as cell array
  389. % contents{get(hObject,'Value')} returns selected item from bwnoise
  390. % --- Executes during object creation, after setting all properties.
  391. function bwnoise_CreateFcn(hObject, eventdata, handles)
  392. % hObject handle to bwnoise (see GCBO)
  393. % eventdata reserved - to be defined in a future version of MATLAB
  394. % handles empty - handles not created until after all CreateFcns called
  395. % Hint: popupmenu controls usually have a white background on Windows.
  396. % See ISPC and COMPUTER.
  397. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  398. set(hObject,'BackgroundColor','white');
  399. end
  400. % % --- Executes on selection change in popupmenu14.
  401. % function popupmenu14_Callback(hObject, eventdata, handles)
  402. % % hObject handle to popupmenu14 (see GCBO)
  403. % % eventdata reserved - to be defined in a future version of MATLAB
  404. % % handles structure with handles and user data (see GUIDATA)
  405. %
  406. % % Hints: contents = get(hObject,'String') returns popupmenu14 contents as cell array
  407. % % contents{get(hObject,'Value')} returns selected item from popupmenu14
  408. %
  409. %
  410. % % --- Executes during object creation, after setting all properties.
  411. % function popupmenu14_CreateFcn(hObject, eventdata, handles)
  412. % % hObject handle to popupmenu14 (see GCBO)
  413. % % eventdata reserved - to be defined in a future version of MATLAB
  414. % % handles empty - handles not created until after all CreateFcns called
  415. %
  416. % % Hint: popupmenu controls usually have a white background on Windows.
  417. % % See ISPC and COMPUTER.
  418. % if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  419. % set(hObject,'BackgroundColor','white');
  420. % end
  421. % --- Executes on selection change in sensorformat.
  422. function sensorformat_Callback(hObject, eventdata, handles)
  423. % hObject handle to sensorformat (see GCBO)
  424. % eventdata reserved - to be defined in a future version of MATLAB
  425. % handles structure with handles and user data (see GUIDATA)
  426. val=get(hObject,'Value');
  427. switch (val)
  428. case 1
  429. handles.output.sensorformat=1;
  430. case 2
  431. handles.output.sensorformat=2;
  432. end
  433. guidata(hObject,handles);
  434. % Hints: contents = get(hObject,'String') returns sensorformat contents as cell array
  435. % contents{get(hObject,'Value')} returns selected item from sensorformat
  436. % --- Executes during object creation, after setting all properties.
  437. function sensorformat_CreateFcn(hObject, eventdata, handles)
  438. % hObject handle to sensorformat (see GCBO)
  439. % eventdata reserved - to be defined in a future version of MATLAB
  440. % handles empty - handles not created until after all CreateFcns called
  441. % Hint: popupmenu controls usually have a white background on Windows.
  442. % See ISPC and COMPUTER.
  443. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  444. set(hObject,'BackgroundColor','white');
  445. end
  446. % --- Executes on button press in Comfirm.
  447. function Comfirm_Callback(hObject, eventdata, handles)
  448. % hObject handle to Comfirm (see GCBO)
  449. % eventdata reserved - to be defined in a future version of MATLAB
  450. % handles structure with handles and user data (see GUIDATA)
  451. uiresume();
  452. function roi_vert_min_Callback(hObject, eventdata, handles)
  453. % hObject handle to roi_vert_min (see GCBO)
  454. % eventdata reserved - to be defined in a future version of MATLAB
  455. % handles structure with handles and user data (see GUIDATA)
  456. x=str2num(get(handles.roi_hori_min,'string'));
  457. w=str2num(get(handles.roi_hori_max,'string'))-x;
  458. y=str2num(get(handles.roi_vert_min,'string'));
  459. h=str2num(get(handles.roi_vert_max,'string'))-y;
  460. if w<=0
  461. w=1;
  462. end
  463. if h<=0
  464. h=1;
  465. end
  466. cla(handles.roi_view);
  467. rectangle('Position',[x,y,w,h]);
  468. % Hints: get(hObject,'String') returns contents of roi_vert_min as text
  469. % str2double(get(hObject,'String')) returns contents of roi_vert_min as a double
  470. % --- Executes during object creation, after setting all properties.
  471. function roi_vert_min_CreateFcn(hObject, eventdata, handles)
  472. % hObject handle to roi_vert_min (see GCBO)
  473. % eventdata reserved - to be defined in a future version of MATLAB
  474. % handles empty - handles not created until after all CreateFcns called
  475. % Hint: edit controls usually have a white background on Windows.
  476. % See ISPC and COMPUTER.
  477. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  478. set(hObject,'BackgroundColor','white');
  479. end
  480. function roi_vert_max_Callback(hObject, eventdata, handles)
  481. % hObject handle to roi_vert_max (see GCBO)
  482. % eventdata reserved - to be defined in a future version of MATLAB
  483. % handles structure with handles and user data (see GUIDATA)
  484. x=str2num(get(handles.roi_hori_min,'string'));
  485. w=str2num(get(handles.roi_hori_max,'string'))-x;
  486. y=str2num(get(handles.roi_vert_min,'string'));
  487. h=str2num(get(handles.roi_vert_max,'string'))-y;
  488. if w<=0
  489. w=1;
  490. end
  491. if h<=0
  492. h=1;
  493. end
  494. cla(handles.roi_view);
  495. rectangle('Position',[x,y,w,h]);
  496. % Hints: get(hObject,'String') returns contents of roi_vert_max as text
  497. % str2double(get(hObject,'String')) returns contents of roi_vert_max as a double
  498. % --- Executes during object creation, after setting all properties.
  499. function roi_vert_max_CreateFcn(hObject, eventdata, handles)
  500. % hObject handle to roi_vert_max (see GCBO)
  501. % eventdata reserved - to be defined in a future version of MATLAB
  502. % handles empty - handles not created until after all CreateFcns called
  503. % Hint: edit controls usually have a white background on Windows.
  504. % See ISPC and COMPUTER.
  505. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  506. set(hObject,'BackgroundColor','white');
  507. end
  508. function roi_hori_min_Callback(hObject, eventdata, handles)
  509. % hObject handle to roi_hori_min (see GCBO)
  510. % eventdata reserved - to be defined in a future version of MATLAB
  511. % handles structure with handles and user data (see GUIDATA)
  512. x=str2num(get(handles.roi_hori_min,'string'));
  513. w=str2num(get(handles.roi_hori_max,'string'))-x;
  514. y=str2num(get(handles.roi_vert_min,'string'));
  515. h=str2num(get(handles.roi_vert_max,'string'))-y;
  516. if w<=0
  517. w=1;
  518. end
  519. if h<=0
  520. h=1;
  521. end
  522. cla(handles.roi_view);
  523. rectangle('Position',[x,y,w,h]);
  524. % Hints: get(hObject,'String') returns contents of roi_hori_min as text
  525. % str2double(get(hObject,'String')) returns contents of roi_hori_min as a double
  526. % --- Executes during object creation, after setting all properties.
  527. function roi_hori_min_CreateFcn(hObject, eventdata, handles)
  528. % hObject handle to roi_hori_min (see GCBO)
  529. % eventdata reserved - to be defined in a future version of MATLAB
  530. % handles empty - handles not created until after all CreateFcns called
  531. % Hint: edit controls usually have a white background on Windows.
  532. % See ISPC and COMPUTER.
  533. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  534. set(hObject,'BackgroundColor','white');
  535. end
  536. function roi_hori_max_Callback(hObject, eventdata, handles)
  537. % hObject handle to roi_hori_max (see GCBO)
  538. % eventdata reserved - to be defined in a future version of MATLAB
  539. % handles structure with handles and user data (see GUIDATA)
  540. x=str2num(get(handles.roi_hori_min,'string'));
  541. w=str2num(get(handles.roi_hori_max,'string'))-x;
  542. y=str2num(get(handles.roi_vert_min,'string'));
  543. h=str2num(get(handles.roi_vert_max,'string'))-y;
  544. if w<=0
  545. w=1;
  546. end
  547. if h<=0
  548. h=1;
  549. end
  550. cla(handles.roi_view);
  551. rectangle('Position',[x,y,w,h]);
  552. % Hints: get(hObject,'String') returns contents of roi_hori_max as text
  553. % str2double(get(hObject,'String')) returns contents of roi_hori_max as a double
  554. % --- Executes during object creation, after setting all properties.
  555. function roi_hori_max_CreateFcn(hObject, eventdata, handles)
  556. % hObject handle to roi_hori_max (see GCBO)
  557. % eventdata reserved - to be defined in a future version of MATLAB
  558. % handles empty - handles not created until after all CreateFcns called
  559. % Hint: edit controls usually have a white background on Windows.
  560. % See ISPC and COMPUTER.
  561. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  562. set(hObject,'BackgroundColor','white');
  563. end
  564. % --- Executes on button press in settomax.
  565. function settomax_Callback(hObject, eventdata, handles)
  566. % hObject handle to settomax (see GCBO)
  567. % eventdata reserved - to be defined in a future version of MATLAB
  568. % handles structure with handles and user data (see GUIDATA)
  569. set(handles.roi_vert_min,'string', '1');
  570. set(handles.roi_vert_max,'string', '2048');
  571. set(handles.roi_hori_min,'string', '1');
  572. set(handles.roi_hori_max,'string', '2048');
  573. cla(handles.roi_view);
  574. rectangle('Position',[1,1,2048,2048]);
  575. function conversion_Callback(hObject, eventdata, handles)
  576. % hObject handle to conversion (see GCBO)
  577. % eventdata reserved - to be defined in a future version of MATLAB
  578. % handles structure with handles and user data (see GUIDATA)
  579. % Hints: get(hObject,'String') returns contents of conversion as text
  580. % str2double(get(hObject,'String')) returns contents of conversion as a double
  581. % --- Executes during object creation, after setting all properties.
  582. function conversion_CreateFcn(hObject, eventdata, handles)
  583. % hObject handle to conversion (see GCBO)
  584. % eventdata reserved - to be defined in a future version of MATLAB
  585. % handles empty - handles not created until after all CreateFcns called
  586. % Hint: edit controls usually have a white background on Windows.
  587. % See ISPC and COMPUTER.
  588. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  589. set(hObject,'BackgroundColor','white');
  590. end
  591. function cooling_Callback(hObject, eventdata, handles)
  592. % hObject handle to cooling (see GCBO)
  593. % eventdata reserved - to be defined in a future version of MATLAB
  594. % handles structure with handles and user data (see GUIDATA)
  595. % Hints: get(hObject,'String') returns contents of cooling as text
  596. % str2double(get(hObject,'String')) returns contents of cooling as a double
  597. % --- Executes during object creation, after setting all properties.
  598. function cooling_CreateFcn(hObject, eventdata, handles)
  599. % hObject handle to cooling (see GCBO)
  600. % eventdata reserved - to be defined in a future version of MATLAB
  601. % handles empty - handles not created until after all CreateFcns called
  602. % Hint: edit controls usually have a white background on Windows.
  603. % See ISPC and COMPUTER.
  604. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  605. set(hObject,'BackgroundColor','white');
  606. end
  607. % --- Executes on selection change in offsetctrl.
  608. function offsetctrl_Callback(hObject, eventdata, handles)
  609. % hObject handle to offsetctrl (see GCBO)
  610. % eventdata reserved - to be defined in a future version of MATLAB
  611. % handles structure with handles and user data (see GUIDATA)
  612. val=get(hObject,'Value');
  613. switch (val)
  614. case 1
  615. handles.output.offsetctrl=1;
  616. case 2
  617. handles.output.offsetctrl=2;
  618. end
  619. guidata(hObject,handles);
  620. % Hints: contents = get(hObject,'String') returns offsetctrl contents as cell array
  621. % contents{get(hObject,'Value')} returns selected item from offsetctrl
  622. % --- Executes during object creation, after setting all properties.
  623. function offsetctrl_CreateFcn(hObject, eventdata, handles)
  624. % hObject handle to offsetctrl (see GCBO)
  625. % eventdata reserved - to be defined in a future version of MATLAB
  626. % handles empty - handles not created until after all CreateFcns called
  627. % Hint: popupmenu controls usually have a white background on Windows.
  628. % See ISPC and COMPUTER.
  629. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  630. set(hObject,'BackgroundColor','white');
  631. end
  632. % --- Executes when user attempts to close ROI.
  633. function ROI_CloseRequestFcn(hObject, eventdata, handles)
  634. % hObject handle to ROI (see GCBO)
  635. % eventdata reserved - to be defined in a future version of MATLAB
  636. % handles structure with handles and user data (see GUIDATA)
  637. % Hint: delete(hObject) closes the figure
  638. % delete(hObject);
  639. uiresume();
  640. function Self_SetupCombines(handles,output)
  641. % pop up menu
  642. if isfield(output,'trigmode')
  643. set(handles.trigmode,'Value', output.trigmode);
  644. end
  645. if isfield(output,'recordmode')
  646. set(handles.recordmode,'Value', output.recordmode);
  647. end
  648. if isfield(output,'acquiremode')
  649. set(handles.acquiremode,'Value', output.acquiremode);
  650. end
  651. if isfield(output,'timestamp')
  652. set(handles.timestamp,'Value', output.timestamp);
  653. end
  654. if isfield(output,'bin_horizon')
  655. set(handles.bin_horizon,'Value', output.bin_horizon);
  656. end
  657. if isfield(output,'bin_vertical')
  658. set(handles.bin_vertical,'Value', output.bin_vertical);
  659. end
  660. if isfield(output,'adconverter')
  661. set(handles.adconverter,'Value', output.adconverter);
  662. end
  663. if isfield(output,'pixelclock')
  664. set(handles.pixelclock,'Value', output.pixelclock);
  665. end
  666. if isfield(output,'doubleimage')
  667. set(handles.doubleimage,'Value', output.doubleimage);
  668. end
  669. if isfield(output,'offsetctrl')
  670. set(handles.offsetctrl,'Value', output.offsetctrl);
  671. end
  672. if isfield(output,'bwnoise')
  673. set(handles.bwnoise,'Value', output.bwnoise);
  674. end
  675. if isfield(output,'sensorformat')
  676. set(handles.sensorformat,'Value', output.sensorformat);
  677. end
  678. % edit
  679. if isfield(output,'exposure')
  680. set(handles.exposure,'string', sprintf('%6.6f',output.exposure));
  681. end
  682. if isfield(output,'delay')
  683. set(handles.delay,'string', sprintf('%6.6f',output.delay));
  684. end
  685. if isfield(output,'conversion')
  686. set(handles.conversion,'string', sprintf('%6.2f',output.conversion));
  687. end
  688. if isfield(output,'cooling')
  689. set(handles.cooling,'string', sprintf('%2.2f',output.cooling));
  690. end
  691. if isfield(output,'roi_vert_min')
  692. set(handles.roi_vert_min,'string', int2str(output.roi_vert_min));
  693. end
  694. if isfield(output,'roi_vert_max')
  695. set(handles.roi_vert_max,'string', int2str(output.roi_vert_max));
  696. end
  697. if isfield(output,'roi_hori_min')
  698. set(handles.roi_hori_min,'string', int2str(output.roi_hori_min));
  699. end
  700. if isfield(output,'roi_hori_max')
  701. set(handles.roi_hori_max,'string', int2str(output.roi_hori_max));
  702. end
  703. function output=Self_GetEditValue(handles,output)
  704. % exposure
  705. str= get(handles.exposure,'string');
  706. if ~isempty(str)
  707. dat=(str2double(str));
  708. if ~isnan(dat)
  709. output.exposure=dat;
  710. else
  711. output.exposure=10;
  712. end
  713. end
  714. % delay
  715. str= get(handles.delay,'string');
  716. if ~isempty(str)
  717. dat=(str2double(str));
  718. if ~isnan(dat)
  719. output.delay=dat;
  720. else
  721. output.delay=0;
  722. end
  723. end
  724. % conversion
  725. str= get(handles.conversion,'string');
  726. if ~isempty(str)
  727. dat=(str2double(str));
  728. if ~isnan(dat)
  729. output.conversion=dat;
  730. else
  731. output.conversion=1;
  732. end
  733. end
  734. % cooling
  735. str= get(handles.cooling,'string');
  736. if ~isempty(str)
  737. dat=(str2double(str));
  738. if ~isnan(dat)
  739. output.cooling=dat;
  740. else
  741. output.cooling=10;
  742. end
  743. end
  744. % roi_vert_min
  745. str= get(handles.roi_vert_min,'string');
  746. if ~isempty(str)
  747. dat=(str2double(str));
  748. if ~isnan(dat)
  749. output.roi_vert_min=int32(dat);
  750. else
  751. output.roi_vert_min=1;
  752. end
  753. end
  754. % roi_vert_max
  755. str= get(handles.roi_vert_max,'string');
  756. if ~isempty(str)
  757. dat=(str2double(str));
  758. if ~isnan(dat)
  759. output.roi_vert_max=int32(dat);
  760. else
  761. output.roi_vert_max=2048;
  762. end
  763. end
  764. % roi_hori_min
  765. str= get(handles.roi_hori_min,'string');
  766. if ~isempty(str)
  767. dat=(str2double(str));
  768. if ~isnan(dat)
  769. output.roi_hori_min=int32(dat);
  770. else
  771. output.roi_hori_min=1;
  772. end
  773. end
  774. % roi_hori_max
  775. str= get(handles.roi_hori_max,'string');
  776. if ~isempty(str)
  777. dat=(str2double(str));
  778. if ~isnan(dat)
  779. output.roi_hori_max=int32(dat);
  780. else
  781. output.roi_hori_max=2048;
  782. end
  783. end
  784. % --- Executes on mouse press over axes background.
  785. function roi_view_ButtonDownFcn(hObject, eventdata, handles)
  786. % hObject handle to roi_view (see GCBO)
  787. % eventdata reserved - to be defined in a future version of MATLAB
  788. % handles structure with handles and user data (see GUIDATA)
  789. handles.drawrect=1;
  790. handles.firstpos = int32(get(hObject,'currentpoint'));
  791. set(handles.roi_vert_min,'string',int2str(handles.firstpos(3)));
  792. set(handles.roi_hori_min,'string',int2str(handles.firstpos(1)));
  793. guidata(hObject,handles);
  794. % --- Executes on mouse press over figure background, over a disabled or
  795. % --- inactive control, or over an axes background.
  796. function ROI_WindowButtonDownFcn(hObject, eventdata, handles)
  797. % hObject handle to ROI (see GCBO)
  798. % eventdata reserved - to be defined in a future version of MATLAB
  799. % handles structure with handles and user data (see GUIDATA)
  800. % --- Executes on mouse motion over figure - except title and menu.
  801. function ROI_WindowButtonMotionFcn(hObject, eventdata, handles)
  802. % hObject handle to ROI (see GCBO)
  803. % eventdata reserved - to be defined in a future version of MATLAB
  804. % handles structure with handles and user data (see GUIDATA)
  805. F = get(hObject,'currentpoint'); % The current point w.r.t the figure.
  806. % Figure out of the current point is over the axes or not -> logicals.
  807. tf1 = handles.AXP(1) <= F(1) && F(1) <= handles.AXP(1) + handles.AXP(3);
  808. tf2 = handles.AXP(2) <= F(2) && F(2) <= handles.AXP(2) + handles.AXP(4);
  809. if tf1 && tf2
  810. if handles.last~=1
  811. handles.last=1;
  812. guidata(hObject,handles);
  813. set(gcf,'Pointer','crosshair');
  814. end
  815. if handles.drawrect==1
  816. F=get(handles.roi_view,'currentpoint');
  817. x=min(handles.firstpos(1),F(1));
  818. y=min(handles.firstpos(3),F(3));
  819. w=abs(F(1)-handles.firstpos(1));
  820. if w<= 0
  821. w=1;
  822. end
  823. h=abs(F(3)-handles.firstpos(3));
  824. if h<= 0
  825. h=1;
  826. end
  827. cla(handles.roi_view);
  828. rectangle('Position',[x,y,w,h]);
  829. set(handles.roi_vert_max,'string',int2str(max([F(3),handles.firstpos(3)])));
  830. set(handles.roi_hori_max,'string',int2str(max([F(1),handles.firstpos(1)])));
  831. set(handles.roi_vert_min,'string',int2str(min([F(3),handles.firstpos(3)])));
  832. set(handles.roi_hori_min,'string',int2str(min([F(1),handles.firstpos(1)])));
  833. end
  834. else
  835. if handles.last~=0
  836. handles.last=0;
  837. guidata(hObject,handles);
  838. set(gcf,'Pointer','arrow');
  839. end
  840. end
  841. % --- Executes on mouse press over figure background, over a disabled or
  842. % --- inactive control, or over an axes background.
  843. function ROI_WindowButtonUpFcn(hObject, eventdata, handles)
  844. % hObject handle to ROI (see GCBO)
  845. % eventdata reserved - to be defined in a future version of MATLAB
  846. % handles structure with handles and user data (see GUIDATA)
  847. handles.drawrect=0;
  848. guidata(hObject,handles);