PageRenderTime 27ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/ATF2/FlightSim/testApps/bpmquad_offset/device_type.m

http://atf2flightsim.googlecode.com/
MATLAB | 206 lines | 94 code | 36 blank | 76 comment | 10 complexity | f696c6e28822769db2af6c93a4a2eb09 MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. function varargout = device_type(varargin)
  2. % DEVICE_TYPE M-file for device_type.fig
  3. % DEVICE_TYPE by itself, creates a new DEVICE_TYPE or raises the
  4. % existing singleton*.
  5. %
  6. % H = DEVICE_TYPE returns the handle to a new DEVICE_TYPE or the handle to
  7. % the existing singleton*.
  8. %
  9. % DEVICE_TYPE('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in DEVICE_TYPE.M with the given input arguments.
  11. %
  12. % DEVICE_TYPE('Property','Value',...) creates a new DEVICE_TYPE or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before device_type_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to device_type_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 device_type
  23. % Last Modified by GUIDE v2.5 04-Nov-2008 14:05:46
  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', @device_type_OpeningFcn, ...
  29. 'gui_OutputFcn', @device_type_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 device_type is made visible.
  42. function device_type_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 device_type (see VARARGIN)
  48. % Choose default command line output for device_type
  49. handles.output = 'quads';
  50. % Update handles structure
  51. guidata(hObject, handles);
  52. % Insert custom Title and Text if specified by the user
  53. % Hint: when choosing keywords, be sure they are not easily confused
  54. % with existing figure properties. See the output of set(figure) for
  55. % a list of figure properties.
  56. if(nargin > 3)
  57. for index = 1:2:(nargin-3),
  58. if nargin-3==index, break, end
  59. switch lower(varargin{index})
  60. case 'title'
  61. set(hObject, 'Name', varargin{index+1});
  62. case 'string'
  63. set(handles.text1, 'String', varargin{index+1});
  64. end
  65. end
  66. end
  67. % Determine the position of the dialog - centered on the callback figure
  68. % if available, else, centered on the screen
  69. FigPos=get(0,'DefaultFigurePosition');
  70. OldUnits = get(hObject, 'Units');
  71. set(hObject, 'Units', 'pixels');
  72. OldPos = get(hObject,'Position');
  73. FigWidth = OldPos(3);
  74. FigHeight = OldPos(4);
  75. if isempty(gcbf)
  76. ScreenUnits=get(0,'Units');
  77. set(0,'Units','pixels');
  78. ScreenSize=get(0,'ScreenSize');
  79. set(0,'Units',ScreenUnits);
  80. FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
  81. FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
  82. else
  83. GCBFOldUnits = get(gcbf,'Units');
  84. set(gcbf,'Units','pixels');
  85. GCBFPos = get(gcbf,'Position');
  86. set(gcbf,'Units',GCBFOldUnits);
  87. FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ...
  88. (GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2];
  89. end
  90. FigPos(3:4)=[FigWidth FigHeight];
  91. set(hObject, 'Position', FigPos);
  92. set(hObject, 'Units', OldUnits);
  93. % Show a question icon from dialogicons.mat - variables questIconData
  94. % and questIconMap
  95. load dialogicons.mat
  96. IconData=questIconData;
  97. questIconMap(256,:) = get(handles.figure1, 'Color');
  98. IconCMap=questIconMap;
  99. Img=image(IconData, 'Parent', handles.axes1);
  100. set(handles.figure1, 'Colormap', IconCMap);
  101. set(handles.axes1, ...
  102. 'Visible', 'off', ...
  103. 'YDir' , 'reverse' , ...
  104. 'XLim' , get(Img,'XData'), ...
  105. 'YLim' , get(Img,'YData') ...
  106. );
  107. % Make the GUI modal
  108. set(handles.figure1,'WindowStyle','modal')
  109. % UIWAIT makes device_type wait for user response (see UIRESUME)
  110. uiwait(handles.figure1);
  111. % --- Outputs from this function are returned to the command line.
  112. function varargout = device_type_OutputFcn(hObject, eventdata, handles)
  113. % varargout cell array for returning output args (see VARARGOUT);
  114. % hObject handle to figure
  115. % eventdata reserved - to be defined in a future version of MATLAB
  116. % handles structure with handles and user data (see GUIDATA)
  117. % Get default command line output from handles structure
  118. varargout{1} = handles.output;
  119. % The figure can be deleted now
  120. delete(handles.figure1);
  121. % --- Executes on button press in pushbutton1.
  122. function pushbutton1_Callback(hObject, eventdata, handles)
  123. % hObject handle to pushbutton1 (see GCBO)
  124. % eventdata reserved - to be defined in a future version of MATLAB
  125. % handles structure with handles and user data (see GUIDATA)
  126. handles.output = lower(get(hObject,'String'));
  127. % Update handles structure
  128. guidata(hObject, handles);
  129. % Use UIRESUME instead of delete because the OutputFcn needs
  130. % to get the updated handles structure.
  131. uiresume(handles.figure1);
  132. % --- Executes on button press in pushbutton2.
  133. function pushbutton2_Callback(hObject, eventdata, handles)
  134. % hObject handle to pushbutton2 (see GCBO)
  135. % eventdata reserved - to be defined in a future version of MATLAB
  136. % handles structure with handles and user data (see GUIDATA)
  137. handles.output = lower(get(hObject,'String'));
  138. % Update handles structure
  139. guidata(hObject, handles);
  140. % Use UIRESUME instead of delete because the OutputFcn needs
  141. % to get the updated handles structure.
  142. uiresume(handles.figure1);
  143. % --- Executes when user attempts to close figure1.
  144. function figure1_CloseRequestFcn(hObject, eventdata, handles)
  145. % hObject handle to figure1 (see GCBO)
  146. % eventdata reserved - to be defined in a future version of MATLAB
  147. % handles structure with handles and user data (see GUIDATA)
  148. if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
  149. % The GUI is still in UIWAIT, us UIRESUME
  150. uiresume(handles.figure1);
  151. else
  152. % The GUI is no longer waiting, just close it
  153. delete(handles.figure1);
  154. end
  155. % --- Executes on key press over figure1 with no controls selected.
  156. function figure1_KeyPressFcn(hObject, eventdata, handles)
  157. % hObject handle to figure1 (see GCBO)
  158. % eventdata reserved - to be defined in a future version of MATLAB
  159. % handles structure with handles and user data (see GUIDATA)
  160. % Check for "enter" or "escape"
  161. if isequal(get(hObject,'CurrentKey'),'escape')
  162. % User said no by hitting escape
  163. handles.output = 'quit';
  164. % Update handles structure
  165. guidata(hObject, handles);
  166. uiresume(handles.figure1);
  167. end
  168. if isequal(get(hObject,'CurrentKey'),'return')
  169. uiresume(handles.figure1);
  170. end