% This file describes how the scene updates are handled in OpenFlipper
% Author: Jan Möbius

\tikzstyle{abstract}=[rectangle, draw=black, rounded corners, fill=blue!30!white, drop shadow,
text centered, text=black, text width=6.5cm]
\tikzstyle{timernode}=[rectangle, draw=black, rounded corners, fill=blue!10!white, drop shadow,
text centered, text=black, text width=3cm]

\tikzstyle{smallnode}=[rectangle, draw=black, rounded corners, fill=blue!30!white, drop shadow,
text centered, text=black, text width=3cm]

\tikzstyle{interactionnode}=[rectangle, draw=black, rounded corners, fill=blue!30!yellow!30, drop shadow,
text centered, text=black, text width=3.5cm]

\tikzstyle{flow}=[->, >= triangle 90, very thick]
\tikzstyle{CoreGroup} = [fill=orange!30!white,rectangle,rounded corners,draw,inner sep =0.4cm]
\tikzstyle{PluginGroup} = [fill=orange!50!white,rectangle,rounded corners,draw,inner sep =0.4cm]


\begin{center}
\begin{tikzpicture}[node distance=1cm]








\node (signalUpdatedObject) [abstract, rectangle]
{
\textbf{signal BaseInterface::updatedObject()}
};

\node (Plugins) [above=of signalUpdatedObject,yshift=-0.3cm] {\textbf{\huge{OpenFlipper Plugins}} };

\node (signalUpdateView) [abstract, rectangle, below= of signalUpdatedObject ]
{
\textbf{signal BaseInterface::updateView()}
};

\node (pluginViewChange) [interactionnode, rectangle, below = of signalUpdateView]
{
\textbf{Plugin view changes}
};



\node (slotViewChanged)[abstract, rectangle, below=of pluginViewChange ]
{
\textbf{slot BaseInterface::slotViewChanged()}
};

\node (slotSceneDrawn)[abstract, rectangle, below=of slotViewChanged, yshift=-2.4cm ]
{
\textbf{slot BaseInterface::slotSceneDrawn()}
};


\node (coreUpdateHandling) [abstract, rectangle, left= of signalUpdateView, xshift=-1.6cm ]
{
\textbf{Update Handling}
};
\node (AuxNode) [above=of coreUpdateHandling]{};




\node (Core) [above=of coreUpdateHandling ,yshift=1.3cm] {\textbf{\huge{OpenFlipper Core}} };


\node (viewManagement) [smallnode, rectangle, below= of coreUpdateHandling,yshift=-1.5cm]
{
\textbf{View Managment}
};


\node (userViewChange) [interactionnode, rectangle, above= of viewManagement,xshift=-2.1cm] 
{
\textbf{User View changes}
};

\node (redraw) [abstract, rectangle, below= of viewManagement , yshift=-2cm]
{
\textbf{Redraw Scene}
};

\node (timer) [timernode, rectangle, above= of redraw,xshift=-2cm]
{
\textbf{Redraw Timer}
};
\node [label=above:emitted] (X) at ($ (coreUpdateHandling)!.5!(signalUpdateView) $) {};
\node [label=above:emitted] (X) at ($ (AuxNode)!.5!(signalUpdatedObject) $) {};
\node [label=above:per plugin,yshift=-3] (X) at ($ (viewManagement)!.78!(slotViewChanged.west) $) {};
\node [label=right:update time reached] (X) at ($ (viewManagement)!.57!(redraw) $) {};
\node [label=left:too many updates] (X) at ($ (viewManagement)!.4!(timer) $) {};
\node [label=above:per plugin,yshift=-3] (X) at ($ (redraw.south)!.78!(slotSceneDrawn.west) $) {};

\draw[flow] (pluginViewChange.west) -- ++(0,0) -| (viewManagement.north);
\draw[flow] (userViewChange.south) -- ++(0,-0.5cm) -| (viewManagement.north);
\draw[flow] (viewManagement.east) -- ++(0,0) |- (slotViewChanged.west);
\draw[flow] (coreUpdateHandling.south) -- ++(0,0) -| (viewManagement.north);
\draw[flow] (signalUpdatedObject.west) -- ++(0,0) -| (coreUpdateHandling.north);
\draw[flow] (viewManagement.south) -- ++(0,0) -| (redraw.north);
\draw[flow] (viewManagement.south) -- ++(0,-0.9) -| (timer.north);
\draw[flow] (signalUpdateView.west) --  ++(0,0) |-  (coreUpdateHandling.east);
\draw[flow] (timer.south) --  ++(0,-0.4) -|  (redraw.north);
\draw[flow] (redraw.south) --  ++(0,0) |-  (slotSceneDrawn.west);

\begin{pgfonlayer}{background}
\node[CoreGroup,fit=(Core) (redraw) (userViewChange) ] (Core) {};
\node[PluginGroup,fit=(Plugins) (signalUpdatedObject) (slotSceneDrawn) ] (Plugin) {};
\end{pgfonlayer}


\end{tikzpicture}
\end{center}
