Line data Source code
1 :
2 : /* Copyright (c) 2011, Stefan Eilemann <eile@eyescale.ch>
3 : * 2012, 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 : #include <eq/client/config.h>
28 : #ifndef EQ_2_0_API
29 : # include <eq/client/configEvent.h>
30 : #endif
31 : #include <eq/client/eventICommand.h>
32 :
33 : namespace seq
34 : {
35 : namespace detail
36 : {
37 :
38 8 : View::View( eq::Layout* parent )
39 8 : : eq::View( parent )
40 8 : {}
41 :
42 16 : View::~View()
43 : {
44 16 : }
45 :
46 14 : Config* View::getConfig()
47 : {
48 14 : return static_cast< Config* >( eq::View::getConfig( ));
49 : }
50 :
51 16 : Pipe* View::getPipe()
52 : {
53 16 : return static_cast< Pipe* >( eq::View::getPipe( ));
54 : }
55 :
56 9 : ViewData* View::getViewData()
57 : {
58 9 : return static_cast< ViewData* >( eq::View::getUserData( ));
59 : }
60 :
61 1 : const ViewData* View::getViewData() const
62 : {
63 1 : return static_cast< const ViewData* >( eq::View::getUserData( ));
64 : }
65 :
66 8 : void View::notifyAttach()
67 : {
68 8 : eq::View::notifyAttach();
69 8 : Pipe* pipe = getPipe();
70 :
71 8 : if( pipe ) // render client view
72 1 : setUserData( pipe->getRenderer()->createViewData( ));
73 : else // application view
74 7 : setUserData( getConfig()->getApplication()->createViewData( ));
75 8 : }
76 :
77 8 : void View::notifyDetached()
78 : {
79 8 : ViewData* data = getViewData();
80 8 : setUserData( 0 );
81 :
82 8 : if( data )
83 : {
84 8 : Pipe* pipe = getPipe();
85 :
86 8 : if( pipe ) // render client view
87 1 : pipe->getRenderer()->destroyViewData( data );
88 : else // application view
89 7 : getConfig()->getApplication()->destroyViewData( data );
90 : }
91 :
92 8 : eq::View::notifyDetached();
93 8 : }
94 :
95 7 : bool View::updateData()
96 : {
97 7 : if( !isActive( ))
98 6 : return false;
99 :
100 1 : ViewData* data = getViewData();
101 1 : LBASSERT( data );
102 1 : if( data )
103 1 : return data->update();
104 0 : return false;
105 : }
106 :
107 : #ifndef EQ_2_0_API
108 0 : bool View::handleEvent( const eq::ConfigEvent* event )
109 : {
110 0 : ViewData* data = getViewData();
111 0 : LBASSERT( data );
112 0 : if( !data )
113 0 : return false;
114 0 : if( isActive( ))
115 0 : return data->handleEvent( event );
116 0 : data->handleEvent( event );
117 0 : return false;
118 : }
119 : #endif
120 :
121 0 : bool View::handleEvent( const eq::EventICommand& command )
122 : {
123 0 : ViewData* data = getViewData();
124 0 : LBASSERT( data );
125 0 : if( !data )
126 0 : return false;
127 0 : if( isActive( ))
128 0 : return data->handleEvent( command );
129 0 : data->handleEvent( command );
130 0 : return false;
131 : }
132 : }
133 3 : }
|