LCOV - code coverage report
Current view: top level - seq/detail - view.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 47 75 62.7 %
Date: 2017-12-16 05:07:20 Functions: 14 24 58.3 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011-2017, Stefan Eilemann <eile@eyescale.ch>
       3             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #include "view.h"
      20             : 
      21             : #include "config.h"
      22             : #include "pipe.h"
      23             : 
      24             : #include <seq/application.h>
      25             : #include <seq/renderer.h>
      26             : #include <seq/viewData.h>
      27             : 
      28             : #include <eq/config.h>
      29             : #include <eq/eventICommand.h>
      30             : 
      31             : namespace seq
      32             : {
      33             : namespace detail
      34             : {
      35           8 : View::View(eq::Layout* parent)
      36           8 :     : eq::View(parent)
      37             : {
      38           8 : }
      39             : 
      40          16 : View::~View()
      41             : {
      42          16 : }
      43             : 
      44          14 : Config* View::getConfig()
      45             : {
      46          14 :     return static_cast<Config*>(eq::View::getConfig());
      47             : }
      48             : 
      49          23 : Pipe* View::getPipe()
      50             : {
      51          23 :     return static_cast<Pipe*>(eq::View::getPipe());
      52             : }
      53             : 
      54          16 : ViewData* View::getViewData()
      55             : {
      56          16 :     return static_cast<ViewData*>(eq::View::getUserData());
      57             : }
      58             : 
      59           1 : const ViewData* View::getViewData() const
      60             : {
      61           1 :     return static_cast<const ViewData*>(eq::View::getUserData());
      62             : }
      63             : 
      64           7 : bool View::configInit()
      65             : {
      66           7 :     if (!eq::View::configInit())
      67           0 :         return false;
      68             : 
      69           7 :     if (!getPipe()) // application view
      70           7 :         setUserData(getConfig()->getApplication()->createViewData(*this));
      71           7 :     return true;
      72             : }
      73             : 
      74           7 : bool View::configExit()
      75             : {
      76           7 :     ViewData* viewData = getViewData();
      77           7 :     if (!getPipe() && viewData) // application view
      78             :     {
      79           7 :         setUserData(0);
      80           7 :         getConfig()->getApplication()->destroyViewData(viewData);
      81             :     }
      82           7 :     return eq::View::configExit();
      83             : }
      84             : 
      85           8 : void View::notifyAttach()
      86             : {
      87           8 :     eq::View::notifyAttach();
      88           8 :     Pipe* pipe = getPipe();
      89             : 
      90           8 :     if (pipe) // render client view
      91           1 :         setUserData(pipe->getRenderer()->createViewData(*this));
      92           8 : }
      93             : 
      94           8 : void View::notifyDetached()
      95             : {
      96           8 :     ViewData* data = getViewData();
      97           8 :     setUserData(0);
      98             : 
      99           8 :     if (data)
     100             :     {
     101           1 :         Pipe* pipe = getPipe();
     102             : 
     103           1 :         if (pipe) // render client view
     104           1 :             pipe->getRenderer()->destroyViewData(data);
     105             :     }
     106             : 
     107           8 :     eq::View::notifyDetached();
     108           8 : }
     109             : 
     110           7 : bool View::updateData()
     111             : {
     112           7 :     if (!isActive())
     113           6 :         return false;
     114             : 
     115           1 :     ViewData* data = getViewData();
     116           1 :     LBASSERT(data);
     117           1 :     if (data)
     118           1 :         return data->update();
     119           0 :     return false;
     120             : }
     121             : 
     122             : template <class E>
     123           0 : bool View::_handleEvent(eq::EventType type, E& event)
     124             : {
     125           0 :     ViewData* data = getViewData();
     126           0 :     LBASSERT(data);
     127           0 :     if (!data)
     128           0 :         return false;
     129           0 :     if (isActive())
     130           0 :         return data->handleEvent(type, event);
     131           0 :     return false;
     132             : }
     133             : 
     134             : template <class E>
     135           0 : bool View::_handleEvent(E& event)
     136             : {
     137           0 :     ViewData* data = getViewData();
     138           0 :     LBASSERT(data);
     139           0 :     if (!data)
     140           0 :         return false;
     141           0 :     if (isActive())
     142           0 :         return data->handleEvent(event);
     143           0 :     return false;
     144             : }
     145             : 
     146           0 : bool View::handleEvent(eq::EventType type, const SizeEvent& event)
     147             : {
     148           0 :     return _handleEvent(type, event);
     149             : }
     150             : 
     151           0 : bool View::handleEvent(eq::EventType type, const PointerEvent& event)
     152             : {
     153           0 :     return _handleEvent(type, event);
     154             : }
     155             : 
     156           0 : bool View::handleEvent(eq::EventType type, const KeyEvent& event)
     157             : {
     158           0 :     return _handleEvent(type, event);
     159             : }
     160             : 
     161           0 : bool View::handleEvent(const AxisEvent& event)
     162             : {
     163           0 :     return _handleEvent(event);
     164             : }
     165             : 
     166           0 : bool View::handleEvent(const ButtonEvent& event)
     167             : {
     168           0 :     return _handleEvent(event);
     169             : }
     170             : }
     171          30 : }

Generated by: LCOV version 1.11