KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
makedatatip.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
17 function varargout = makedatatip(hObj,index) {
18 
19 
20 /* Author: Tim Farajian
21  * Release: 2.0
22  * Release date: 6/27/2012 */
23 
24 /* Check # of inputs */
25 narginchk(2, 2)
26 nargoutchk(0, 1)
27 
28 if length(hObj)~=1
29  error(" MAKEDATATIP:InvalidSize ",...
30  " HOBJ must be scalar. ");
31 end
32 
33 /* Ensure hObj is valid target */
34 if ~ishandle(hObj)
35  error(" MAKEDATATIP:InvalidHandle ",...
36  " HOBJ is an invalid handle object. ");
37 end
38 
39 isImage = strcmp(get(hObj, " Type "), " image "); /* Determine if target is image */
40 
41 
42 /* Read data from hObj */
43 try
44  X = get(hObj," XData ");
45  Y = get(hObj," YData ");
46 catch ME
47  /* Object must have an XData and YData property to be valid */
48  error(" MAKEDATATIP:InvalidObjectType ",...
49  " Objects of class "" %s "" are not a valid targets for datatips. ",...
50  class(handle(hObj)))
51 end
52 try
53  Z = get(hObj," ZData ");
54 catch ME
55  /* Many objects do not have a ZData property. Some will work, some will
56  * not. */
57  isImage = true;
58 end
59 /* Ensure subscripts or indices are valid values and sizes */
60 if isempty(index)
61  return
62 elseif ~isnumeric(index)
63  error(" MAKEDATATIP:InvalidDataType ",...
64  " Subscript indices must be of numeric data type. ")
65 elseif any(index(:)<1) ||...
66  any(fix(index(:))~=index(:)) ||...
67  any(isinf(index(:)))
68  error(" MAKEDATATIP:InvalidIndex ",...
69  " Subscript indices must be positive integers. ")
70 elseif ~isvector(index) && ~any(size(index)==2)
71  error(" MAKEDATATIP:InvalidIndexMatrixSize ",...
72  " Subscript indices must be a vector or N-by-2 matrix. ")
73 elseif (~isImage && isvector(X)) || size(index,2)~=2
74  hDatatip = zeros(size(index));
75  index = index(:);
76  isLinear = true;
77 else
78  hDatatip = zeros(size(index,1),1);
79  isLinear = false;
80 end
81 
82 /* Get handle to datacursor mode object */
83 hDataCursorMgr = datacursormode(ancestor(hObj," figure "));
84 
85 /* Loop through each specified data point */
86 for n = 1:size(index,1)
87 
88  /* Create position vector */
89  if isImage && isLinear
90  [i j] = ind2sub([X(2) Y(2)], index(n));
91  pos = [i j 1];
92  elseif isImage
93  pos = [index(n, 1) index(n, 2) 1];
94  elseif isempty(Z)
95  pos = [X(index(n)) Y(index(n))];
96  elseif isLinear
97  pos = [X(index(n)) Y(index(n)) Z(index(n))];
98  else
99  pos = [...
100  X(index(n,1),index(n,2))...
101  Y(index(n,1),index(n,2))...
102  Z(index(n,1),index(n,2))];
103  end
104 
105  /* Create datatip */
106  hDatatip(n) = createDatatip(hDataCursorMgr, hObj);
107  /* Specify data cursor properties */
108  if isImage
109  set(get(hDatatip(n)," DataCursor ")," DataIndex ",pos,...
110  " TargetPoint ",pos(1:2))
111  else
112  set(get(hDatatip(n)," DataCursor ")," DataIndex ",index(n, :),...
113  " TargetPoint ",pos)
114  end
115 
116  /* Specify datatip properties */
117  set(hDatatip(n)," Position ",pos)
118 
119 end
120 
121 /* Update all data cursors */
122 updateDataCursors(hDataCursorMgr)
123 
124 /* Return handles if requested */
125 if nargout==1
126  varargout = [hDatatip];
127 end
128 }
Matlab's base handle class (documentation generation substitute)
function varargout = makedatatip(hObj, index)
MAKEDATATIP Adds data tips to specified data points of graphical objects.
Definition: makedatatip.m:17
#define X(i, j)
#define Y(i, j)
A variable number of output arguments.