PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kputicon.m

http://github.com/aludnam/MATLAB
Objective C | 254 lines | 251 code | 3 blank | 0 comment | 59 complexity | 62e5ec19dd8e8e2b5110f1918f3952cd MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kputicon 'Non-Interactive Display of Iconified Image'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros puticon.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input File', required: 'File containing image to iconify'
  6. % InputFile: cmap 'Input Colormap ', optional: 'File containing alternate colormap filename'
  7. % InputFile: clip 'Input Clip Gate', optional: 'File containing clip mask'
  8. % Integer: iconsize 'Image Icon Size', default: 100: 'Controls the size of the icon in pixels'
  9. % Integer: x 'X Placement', default: -1: 'X location for GUI autoplacement'
  10. % Integer: width 'Window Width ', default: 50: 'Window width'
  11. % Integer: y 'Y Placement', default: -1: 'Y location for GUI autoplacement'
  12. % Integer: height 'Window Height', default: 50: 'Window height'
  13. % Double: update 'Update time', default: 2: 'How often to check input file for modification'
  14. %
  15. % Example: kputicon({i, cmap, clip}, {'i','';'cmap','';'clip','';'iconsize',100;'x',-1;'width',50;'y',-1;'height',50;'update',2})
  16. %
  17. % Khoros helpfile follows below:
  18. %
  19. % PROGRAM
  20. % puticon - Non-Interactive Display of Iconified Image
  21. %
  22. % DESCRIPTION
  23. % Puticon is a visualization program that displays an iconified
  24. % representation of a data set.
  25. %
  26. % The input file containing the data to be displayed as an icon
  27. % is monitored by default; the file is checked every 2 seconds for
  28. % change, and if it has been modified, the image icon is updated
  29. % accordingly. The interval at which the input file is checked for
  30. % modification may be specified using the [-update] argument.
  31. %
  32. % A clip mask may be used to dictate the portion of the data that
  33. % is displayed as an icon using the [-clip] argument.
  34. %
  35. % An alternate input color map may be used to change the current color map
  36. % using the [-cmap] argument.
  37. %
  38. % A value may be provided to specify the size of the icon in pixels
  39. % using the [-iconsize] argument. The image icon size should be used
  40. % rather than setting "[-width]" and \fI[-height]\fP separately in
  41. % order to preserve the 1:1 aspect ratio of the iconified image.
  42. %
  43. % By default, the visualization display will share its colormap with all
  44. % other applications running at the same time; that is, it does not not use a
  45. % .I private colormap,
  46. % but rather makes use of the
  47. % .I default colormap.
  48. % It is possible to specify that the visualization display allocate its
  49. % own private colormap or "grab" all available colors for its own use.
  50. % This is done using the [-priv] argument. When [-priv] is specified,
  51. % moving the mouse pointer into the display window will cause the display
  52. % to have its private colormap installed; moving the pointer out of the
  53. % display window will cause the private colormap to be de-installed. This
  54. % results in the "technoflashing" phenomenon characteristic of private
  55. % colormap installation.
  56. %
  57. % Color allocation can also be controlled and set to either
  58. % .I Read Only
  59. % or
  60. % .I Read Write
  61. % using the [-alloc] argument. When set to
  62. % .I read only,
  63. % once a color cell has been allocated, it can have its color set only once;
  64. % from then on, the color cell can be shared by multiple applications, but
  65. % not changed. If the visualization display requires the color displayed
  66. % to change, it must re-allocate the color cell, forcing a re-display of
  67. % the data. This can be an expensive procedure. In contrast, after a
  68. % .I read/write
  69. % color cell is allocated, it can have its color changed at any time
  70. % without re-allocation; the data being displayed does not need to be
  71. % redisplayed, and the color update process is much more efficient.
  72. % However, the colors used in the visualization display cannot be shared by
  73. % other applications.
  74. %
  75. % On creation, the image icon window may be placed manually (the
  76. % default method), or placed automatically. For automatic placement
  77. % of the image icon window, specify the desired location in device
  78. % (screen) coordinates using the [-x] and [-y] arguments.
  79. %
  80. % While the image icon display window should be created with a default
  81. % size that is appropriate to display the data, a width and height for
  82. % the window can be specified explicitly using the [-width] and
  83. % [-height] arguments. The iconified image will be resized to fit the
  84. % specified dimensions. When width and height are set separately,
  85. % however, the 1:1 aspect ratio of the original image may not be
  86. % maintained. Note that interactive resizing of the image icon
  87. % window using the window manager is currently NOT supported.
  88. %
  89. %
  90. %
  91. % EXAMPLES
  92. % % puticon -i image:ball
  93. % % puticon -i image:lizard
  94. %
  95. % "SEE ALSO"
  96. % putdata(1)
  97. %
  98. % RESTRICTIONS
  99. %
  100. % REFERENCES
  101. %
  102. % COPYRIGHT
  103. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  104. %
  105. function varargout = kputicon(varargin)
  106. if nargin ==0
  107. Inputs={};arglist={'',''};
  108. elseif nargin ==1
  109. Inputs=varargin{1};arglist={'',''};
  110. elseif nargin ==2
  111. Inputs=varargin{1}; arglist=varargin{2};
  112. else error('Usage: [out1,..] = kputicon(Inputs,arglist).');
  113. end
  114. if size(arglist,2)~=2
  115. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  116. end
  117. narglist={'i', '__input';'cmap', '__input';'clip', '__input';'iconsize', 100;'x', -1;'width', 50;'y', -1;'height', 50;'update', 2};
  118. maxval={0,1,1,512,1000,1000,1000,1000,1};
  119. minval={0,1,1,0,-1,-1,-1,-1,1};
  120. istoggle=[0,1,1,1,1,1,1,1,1];
  121. was_set=istoggle * 0;
  122. paramtype={'InputFile','InputFile','InputFile','Integer','Integer','Integer','Integer','Integer','Double'};
  123. % identify the input arrays and assign them to the arguments as stated by the user
  124. if ~iscell(Inputs)
  125. Inputs = {Inputs};
  126. end
  127. NumReqOutputs=0; nextinput=1; nextoutput=1;
  128. for ii=1:size(arglist,1)
  129. wasmatched=0;
  130. for jj=1:size(narglist,1)
  131. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  132. wasmatched = 1;
  133. was_set(jj) = 1;
  134. if strcmp(narglist{jj,2}, '__input')
  135. if (nextinput > length(Inputs))
  136. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  137. end
  138. narglist{jj,2} = 'OK_in';
  139. nextinput = nextinput + 1;
  140. elseif strcmp(narglist{jj,2}, '__output')
  141. if (nextoutput > nargout)
  142. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  143. end
  144. if (isempty(arglist{ii,2}))
  145. narglist{jj,2} = 'OK_out';
  146. else
  147. narglist{jj,2} = arglist{ii,2};
  148. end
  149. nextoutput = nextoutput + 1;
  150. if (minval{jj} == 0)
  151. NumReqOutputs = NumReqOutputs - 1;
  152. end
  153. elseif isstr(arglist{ii,2})
  154. narglist{jj,2} = arglist{ii,2};
  155. else
  156. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  157. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  158. end
  159. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  160. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  161. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  162. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  163. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  164. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  165. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  166. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  167. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  168. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  169. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  170. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  171. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  172. end
  173. end
  174. end
  175. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  176. narglist{jj,2} = arglist{ii,2};
  177. end
  178. end
  179. end
  180. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  181. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  182. end
  183. end
  184. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  185. for jj=1:size(narglist,1)
  186. if strcmp(paramtype{jj}, 'Toggle')
  187. if (narglist{jj,2} ==0)
  188. narglist{jj,1} = '';
  189. end;
  190. narglist{jj,2} = '';
  191. end;
  192. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  193. narglist{jj,1} = '';
  194. narglist{jj,2} = '';
  195. end;
  196. if strcmp(narglist{jj,2}, '__input')
  197. if (minval{jj} == 0) % meaning this input is required
  198. if (nextinput > size(Inputs))
  199. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  200. else
  201. narglist{jj,2} = 'OK_in';
  202. nextinput = nextinput + 1;
  203. end
  204. else % this is an optional input
  205. if (nextinput <= length(Inputs))
  206. narglist{jj,2} = 'OK_in';
  207. nextinput = nextinput + 1;
  208. else
  209. narglist{jj,1} = '';
  210. narglist{jj,2} = '';
  211. end;
  212. end;
  213. else
  214. if strcmp(narglist{jj,2}, '__output')
  215. if (minval{jj} == 0) % this is a required output
  216. if (nextoutput > nargout & nargout > 1)
  217. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  218. else
  219. narglist{jj,2} = 'OK_out';
  220. nextoutput = nextoutput + 1;
  221. NumReqOutputs = NumReqOutputs-1;
  222. end
  223. else % this is an optional output
  224. if (nargout - nextoutput >= NumReqOutputs)
  225. narglist{jj,2} = 'OK_out';
  226. nextoutput = nextoutput + 1;
  227. else
  228. narglist{jj,1} = '';
  229. narglist{jj,2} = '';
  230. end;
  231. end
  232. end
  233. end
  234. end
  235. if nargout
  236. varargout = cell(1,nargout);
  237. else
  238. varargout = cell(0);
  239. end
  240. global KhorosRoot
  241. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  242. w=['"' KhorosRoot];
  243. else
  244. if ispc
  245. w='"C:\Program Files\dip\khorosBin\';
  246. else
  247. [s,w] = system('which cantata');
  248. w=['"' w(1:end-8)];
  249. end
  250. end
  251. callKhoros([w 'putdata" -imageicon'],Inputs,narglist);