diagrams.tex 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. % Define node group background
  2. % The first 4 arguments are nodes that define the group borders in (left,
  3. % top, right, bottom) order, the last argument is a text label
  4. \usetikzlibrary{shapes,arrows,positioning}
  5. \pgfdeclarelayer{background}
  6. \pgfdeclarelayer{foreground}
  7. \pgfsetlayers{background,main,foreground} % Layer order
  8. \newcommand{\group}[5]{
  9. \begin{pgfonlayer}{background}
  10. % Left top corner
  11. \path (#1.west |- #2.north)+(-0.7, 0.7)
  12. node (lefttop) {};
  13. % Right bottom corner
  14. \path (#3.east |- #4.south)+(0.7, -0.4)
  15. node (rightbottom) {};
  16. % Draw rectangle
  17. \path[draw, rounded corners, dashed] (lefttop) rectangle (rightbottom);
  18. % Text label
  19. \path (rightbottom.west |- lefttop.south)+(-1.2, -0.3) node {\emph{#5}};
  20. \end{pgfonlayer}
  21. }
  22. \tikzstyle{block} = [
  23. rectangle,
  24. draw=black,
  25. fill=white,
  26. thick,
  27. minimum height=2em,
  28. text centered,
  29. rounded corners,
  30. text width=6em
  31. ]
  32. \tikzstyle{lineto} = [
  33. ->,
  34. thick,
  35. shorten <= 2pt,
  36. shorten >= 2pt
  37. ]
  38. \tikzstyle{linefrom} = [
  39. <-,
  40. thick,
  41. shorten <= 2pt,
  42. shorten >= 2pt
  43. ]
  44. \newcommand{\architecture}[1]{
  45. \begin{tikzpicture}[node distance=6em, auto]
  46. \node[block] (driver) {Driver};
  47. #1
  48. \end{tikzpicture}
  49. }
  50. \def\basicdiagram{
  51. \begin{figure}[h]
  52. \center
  53. \architecture{
  54. \node[block, dashed, below of=driver] (arch) {Architecture}
  55. edge[linefrom] node[right] {driver-specific messages} (driver);
  56. \node[block, below of=arch] {Application}
  57. edge[linefrom] node[right] {gestures} (arch);
  58. }
  59. \caption{A diagram showing the position of the architecture relative to
  60. the device driver and a multi-touch application. The input of the
  61. architecture is given by a touch device driver. The output is
  62. translated to complex interaction gestures and passed to the
  63. application that is using the architecture.}
  64. \label{fig:basicdiagram}
  65. \end{figure}
  66. }
  67. \def\driverdiagram{
  68. \begin{figure}[H]
  69. \center
  70. \architecture{
  71. \node[block, below of=driver] (eventdriver) {Event driver}
  72. edge[linefrom] node[right, near end] {driver-specific messages} (driver);
  73. \node[block, below of=eventdriver, dashed] (analysis) {Event analysis}
  74. edge[linefrom] node[right] {events} (eventdriver);
  75. \node[block, below of=analysis] {Application}
  76. edge[linefrom] node[right, near start] {gestures} (analysis);
  77. \node[right of=eventdriver, xshift=2em] (dummy) {};
  78. \group{eventdriver}{eventdriver}{dummy}{analysis}{Architecture}
  79. }
  80. \caption{Extension of the diagram from figure \ref{fig:basicdiagram},
  81. showing the position of the event driver in the architecture. The
  82. event driver translates driver-specific to a common set of events,
  83. which are delegated to analysis components that will interpret them
  84. as more complex gestures.}
  85. \label{fig:driverdiagram}
  86. \end{figure}
  87. }
  88. \def\multipledriversdiagram{
  89. \begin{figure}[H]
  90. \center
  91. \begin{tikzpicture}[node distance=6em]
  92. \node[block] (driver) {Driver};
  93. \node[block, below of=driver] (eventdriver) {Event driver}
  94. edge[linefrom] (driver);
  95. \node[block, right of=driver, xshift=2em] (seconddriver) {Driver};
  96. \node[block, below of=seconddriver] (secondeventdriver) {Event driver}
  97. edge[linefrom] node[right, near end] {driver-specific messages} (seconddriver);
  98. \node[block, below of=eventdriver, dashed] (analysis) {Event analysis}
  99. edge[linefrom] (eventdriver)
  100. edge[linefrom] node[right=5] {events} (secondeventdriver);
  101. \node[block, below of=analysis] {Application}
  102. edge[linefrom] node[right, near start] {gestures} (analysis);
  103. \node[right of=seconddriver, xshift=2em] (dummy) {};
  104. \group{eventdriver}{eventdriver}{dummy}{analysis}{Architecture}
  105. \end{tikzpicture}
  106. \caption{Multiple event drivers running simultaneously.}
  107. \label{fig:multipledrivers}
  108. \end{figure}
  109. }
  110. \def\areadiagram{
  111. \begin{figure}[h]
  112. \center
  113. \architecture{
  114. \node[block, below of=driver] (eventdriver) {Event driver}
  115. edge[linefrom] node[right, near end] {driver-specific messages} (driver);
  116. \node[block, below of=eventdriver] (area) {Event areas}
  117. edge[linefrom] node[right] {events} (eventdriver);
  118. \node[block, right of=area, xshift=7em, dashed] (analysis) {Gesture detection}
  119. edge[linefrom, bend right=10] node[above] {events} (area)
  120. edge[lineto, bend left=10] node[] {gestures} (area);
  121. \node[block, below of=area] {Application}
  122. edge[linefrom] node[right, near start] {gestures through callback function} (area);
  123. \group{eventdriver}{eventdriver}{analysis}{area}{Architecture}
  124. }
  125. \caption{Extension of the diagram from figure \ref{fig:driverdiagram},
  126. with event areas. An event area delegates events to a gesture detection
  127. component that triggers a gesture. The event area then calls the
  128. handlers that are bound to the gesture type by the application.}
  129. \label{fig:areadiagram}
  130. \end{figure}
  131. }
  132. \def\trackerdiagram{
  133. \begin{figure}[h]
  134. \center
  135. \architecture{
  136. \node[block, below of=driver] (eventdriver) {Event driver}
  137. edge[linefrom] node[right, near end] {driver-specific messages} (driver);
  138. \node[block, below of=eventdriver] (area) {Area tree}
  139. edge[linefrom] node[right] {events} (eventdriver);
  140. \node[block, right of=area, xshift=7em] (tracker) {Gesture trackers}
  141. edge[linefrom, bend right=10] node[above] {events} (area)
  142. edge[lineto, bend left=10] node[] {gestures} (area);
  143. \node[block, below of=area] {Application}
  144. edge[linefrom] node[right, near start] {gestures} (area);
  145. \group{eventdriver}{eventdriver}{tracker}{area}{Architecture}
  146. }
  147. \caption{Extension of the diagram from figure \ref{fig:areadiagram},
  148. showing the position of gesture trackers in the architecture.}
  149. \label{fig:trackerdiagram}
  150. \end{figure}
  151. }
  152. \def\examplediagram{
  153. \begin{figure}[h!]
  154. \center
  155. \architecture{
  156. \node[block, below of=driver] (eventdriver) {Event driver}
  157. edge[linefrom] node[right, near end] {driver-specific messages} (driver);
  158. \node[block, below of=eventdriver] (rootarea) {Root area}
  159. edge[linefrom] (eventdriver);
  160. \node[block, right of=rootarea, xshift=4em] {\emph{pinch} tracker}
  161. edge[lineto, dotted, bend left=10] (rootarea)
  162. edge[linefrom, bend right=10] (rootarea);
  163. \node[block, below of=rootarea, xshift=-5em] (circlearea) {Circular area}
  164. edge[linefrom] (rootarea)
  165. edge[lineto, bend left=25] (rootarea);
  166. \node[block, left of=circlearea, xshift=-4em] (dragtracker) {\emph{drag} tracker}
  167. edge[lineto, dotted, bend right=10] (circlearea)
  168. edge[linefrom, bend left=10] (circlearea);
  169. \node[block, below of=rootarea, xshift=5em] (subarea) {Button area}
  170. edge[linefrom] (rootarea)
  171. edge[lineto, bend right=25] (rootarea);
  172. \node[block, right of=subarea, xshift=4em] (tracker) {\emph{tap} tracker}
  173. edge[lineto, dotted, bend left=10] (subarea)
  174. edge[linefrom, bend right=10] (subarea);
  175. \node[block, below of=rootarea, yshift=-5em] {Application}
  176. edge[linefrom, dotted] (circlearea)
  177. edge[linefrom, dotted] (rootarea)
  178. edge[linefrom, dotted] (subarea);
  179. \group{dragtracker}{eventdriver}{tracker}{subarea}{Architecture}
  180. }
  181. \caption{Diagram representation of an extended example, showing the
  182. flow of events and gestures in the architecture. The root area represents
  183. an application windows that can be resized using \emph{pinch} gestures.
  184. The window contains a draggable circle, and a button that listens to
  185. \emph{tap} gestures. Dotted arrows represent a flow of gestures, regular
  186. arrows represent events (unless labeled otherwise).}
  187. \label{fig:examplediagram}
  188. \end{figure}
  189. }
  190. \def\lefthand{\includegraphics[width=50pt]{data/hand.png}}
  191. \def\righthand{\reflectbox{\includegraphics[width=50pt, angle=-45]{data/hand.png}}}
  192. \def\examplefigureone{
  193. \begin{figure}[h!]
  194. \center
  195. % TODO: draw finger touch points as circles with rotating arrow
  196. \begin{tikzpicture}
  197. \draw node[draw, black, minimum width=190, minimum height=140] at (0,0) {};
  198. \draw node[fill=gray!50, draw=black!70, minimum height=40, minimum width=40] at (-1,-1) {\lefthand};
  199. \draw node[] at (1.2,1) {\righthand};
  200. \draw node[draw=black!80, diamond, minimum height=70, minimum width=70] at (1.2,1) {};
  201. \end{tikzpicture}
  202. \caption{Two squares on the screen both listen to rotation. The user
  203. should be able to ``grab'' each of the squares independently and rotate
  204. them at the same time.}
  205. \label{fig:ex1}
  206. \end{figure}
  207. }
  208. \def\examplefiguretwo{
  209. \begin{figure}[h]
  210. \center
  211. \begin{tikzpicture}
  212. \draw node[draw, black, minimum width=190, minimum height=140] at (0,0) {};
  213. \draw node[draw=black!80, diamond, minimum height=50, minimum width=50] at (0.5, 0.3) {};
  214. \draw node[draw=black, diamond, dotted, minimum height=53, minimum width=53] at (0.5, 0.3) {};
  215. \draw node[draw=black, dotted, circle, minimum height=80, minimum width=80] at (0.5, 0.3) {};
  216. \fill (-0.3, -0.4) circle (0.15)
  217. (-0.4, 0.8) circle (0.15)
  218. (-0.1, 1.1) circle (0.15)
  219. (1.3, 0.9) circle (0.15);
  220. \draw (0.15, 0.55) circle (0.15) -- (-0.3, -0.4);
  221. \draw (0.15, 0.55) -- (-0.4, 0.8);
  222. \draw (0.15, 0.55) -- (-0.1, 1.1);
  223. \draw (0.15, 0.55) -- (1.3, 0.9);
  224. \end{tikzpicture}
  225. \caption{A square on the screen listens to rotation. The user can grab
  226. and rotate the square by positioning fingers around (but not in) it and
  227. and performing a rotating motion. An example pose of four fingers is
  228. shown by the filled black circles. While the events all occur in the
  229. dotted \emph{area}, the centroid of the rotation gesture is located in
  230. the square.}
  231. \label{fig:ex2}
  232. \end{figure}
  233. }
  234. \def\eventpropagationfigure{
  235. \begin{figure}[h!]
  236. \center
  237. \subfigure[An event is triggered in the white area. The event is first
  238. delegated to the white area from te gray area (2). After gesture
  239. detection, it is propagated back to the gray area (6) \emph{unless}
  240. propagation has been stopped in the rotation detection component
  241. between (3) and (4).]{
  242. \begin{tikzpicture}[node distance=5.5em]
  243. \draw node[draw=black, minimum width=190, minimum height=140] (screen) at (0,0) {};
  244. \draw node[fill=gray!50, draw=black!70, minimum height=100, minimum width=100] (screen) at (-0.1,-0.1) {};
  245. \draw node[fill=white, draw=black!80, diamond, minimum height=50, minimum width=50] (screen) at (0.3,0.4) {};
  246. \fill (0.4, 0.6) circle (0.15);
  247. \draw node[block, yshift=-10em, xshift=-3em] (driver) {Event driver};
  248. \draw node[block, below of=driver] (gray) {Gray event area}
  249. edge[linefrom] node[left] {1} (driver);
  250. \draw node[block, below of=gray] (white) {White event area}
  251. edge[linefrom, bend left=15] node[left] {2} (gray)
  252. edge[lineto, bend right=15] node[right] {6} (gray);
  253. \draw node[block, right of=white, xshift=4em] {rotation detection}
  254. edge[linefrom, bend right=15] node[above] {3} (white)
  255. edge[lineto, dotted, bend left=15] node[below] {4} (white);
  256. \draw node[block, right of=gray, xshift=4em] {rotation detection}
  257. edge[linefrom, bend right=15] node[above] {7} (gray)
  258. edge[lineto, dotted, bend left=15] node[below] {8} (gray);
  259. \draw node[block, below of=white] {Application}
  260. edge[linefrom, dotted, bend left=65] node[left] {9} (gray)
  261. edge[linefrom, dotted] node[left] {5} (white);
  262. \end{tikzpicture}
  263. }
  264. \quad
  265. \subfigure[An event is triggered in the gray event area, it does not even
  266. reach the white event area.]{
  267. \begin{tikzpicture}[node distance=5.5em]
  268. \draw node[draw=black, minimum width=190, minimum height=140] (screen) at (0,0) {};
  269. \draw node[fill=gray!50, draw=black!70, minimum height=100, minimum width=100] (screen) at (-0.1,-0.1) {};
  270. \draw node[fill=white, draw=black!80, diamond, minimum height=50, minimum width=50] (screen) at (0.3,0.4) {};
  271. \fill (-0.5, -0.7) circle (0.15);
  272. \draw node[block, yshift=-10em, xshift=-3em] (driver) {Event driver};
  273. \draw node[block, below of=driver] (gray) {Gray event area}
  274. edge[linefrom] node[left] {1} (driver);
  275. \draw node[block, below of=gray] (white) {White event area};
  276. \draw node[block, right of=white, xshift=4em] {rotation detection};
  277. \draw node[block, right of=gray, xshift=4em] {rotation detection}
  278. edge[linefrom, bend right=15] node[above] {2} (gray)
  279. edge[lineto, dotted, bend left=15] node[below] {3} (gray);
  280. \draw node[block, below of=white] {Application}
  281. edge[linefrom, dotted, bend left=65] node[left] {4} (gray);
  282. \end{tikzpicture}
  283. }
  284. \caption{Two nested squares both listen to rotation gestures. The two
  285. figures both show a touch object triggering an event, which is
  286. delegated through the event area tree in the order indicated by the numbered
  287. arrow labels. Normal arrows represent events, dotted arrows represent
  288. gestures. Note that the dotted arrows only represent the path a gesture
  289. would travel in the tree \emph{if triggered}, not an actual triggered
  290. gesture.}
  291. \label{fig:eventpropagation}
  292. \end{figure}
  293. }
  294. \def\daemondiagram{
  295. \begin{figure}[h!]
  296. \centering
  297. \begin{tikzpicture}[node distance=4em]
  298. \node[block] (daemon) {Daemon};
  299. \node[block, above of=daemon] (driver) {Device driver}
  300. edge[lineto] (daemon);
  301. \node[block, xshift=-4em, left of=driver] {Device driver}
  302. edge[lineto] (daemon);
  303. \node[block, xshift=4em, right of=driver] {Device driver}
  304. edge[lineto] (daemon);
  305. \node[block, below of=daemon] (app) {Application}
  306. edge[linefrom, dotted] (daemon);
  307. \node[block, xshift=-4em, left of=app] {Application}
  308. edge[linefrom, dotted] (daemon);
  309. \node[block, xshift=4em, right of=app] {Application}
  310. edge[linefrom, dotted] (daemon);
  311. \draw[dashed] (app.north)+(-4, 0.35) -- node[right=4, yshift=1] {Network protocol} ++(4, 0.35);
  312. \end{tikzpicture}
  313. \caption{Daemon setup of an architecture implementation, serving
  314. gestures to multiple applications at the same time.}
  315. \label{fig:daemon}
  316. \end{figure}
  317. }