Line data Source code
1 :
2 : /* Copyright (c) 2009-2011, Stefan Eilemann <eile@equalizergraphics.com>
3 : * 2010, Cedric Stalder <cedric.stalder@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 "canvas.h"
20 :
21 : #include "channel.h"
22 : #include "compound.h"
23 : #include "config.h"
24 : #include "configDestCompoundVisitor.h"
25 : #include "layout.h"
26 : #include "log.h"
27 : #include "node.h"
28 : #include "pipe.h"
29 : #include "segment.h"
30 : #include "view.h"
31 : #include "window.h"
32 :
33 : #include <eq/fabric/paths.h>
34 : #include <co/dataIStream.h>
35 : #include <co/dataOStream.h>
36 : #include <lunchbox/stdExt.h>
37 :
38 : namespace eq
39 : {
40 : namespace server
41 : {
42 : typedef fabric::Canvas< Config, Canvas, Segment, Layout > Super;
43 :
44 223 : Canvas::Canvas( Config* parent )
45 : : Super( parent )
46 223 : , _state( STATE_STOPPED )
47 223 : {}
48 :
49 444 : Canvas::~Canvas()
50 : {
51 444 : }
52 :
53 1310 : Segment* Canvas::getSegment( const SegmentPath& path )
54 : {
55 1310 : const Segments& segments = getSegments();
56 1310 : LBASSERTINFO( segments.size() > path.segmentIndex,
57 : segments.size() << " <= " << path.segmentIndex );
58 :
59 1310 : if( segments.size() <= path.segmentIndex )
60 0 : return 0;
61 :
62 1310 : return segments[ path.segmentIndex ];
63 : }
64 :
65 20 : ServerPtr Canvas::getServer()
66 : {
67 20 : Config* config = getConfig();
68 20 : LBASSERT( config );
69 20 : return ( config ? config->getServer() : 0 );
70 : }
71 :
72 2 : void Canvas::activateLayout( const uint32_t index )
73 : {
74 2 : if( _state == STATE_RUNNING )
75 0 : _switchLayout( getActiveLayoutIndex(), index );
76 : else
77 2 : Super::activateLayout( index );
78 2 : }
79 :
80 8 : void Canvas::init()
81 : {
82 8 : LBASSERT( _state == STATE_STOPPED );
83 8 : _switchLayout( LB_UNDEFINED_UINT32, getActiveLayoutIndex( ));
84 8 : _state = STATE_RUNNING;
85 8 : }
86 :
87 8 : void Canvas::exit()
88 : {
89 8 : LBASSERT( _state == STATE_RUNNING || _state == STATE_DELETE );
90 8 : _switchLayout( getActiveLayoutIndex(), LB_UNDEFINED_UINT32 );
91 8 : if( _state == STATE_RUNNING )
92 8 : _state = STATE_STOPPED;
93 8 : }
94 :
95 16 : void Canvas::_switchLayout( const uint32_t oldIndex, const uint32_t newIndex )
96 : {
97 16 : if( oldIndex == newIndex )
98 0 : return;
99 :
100 16 : const Layouts& layouts = getLayouts();
101 16 : const size_t nLayouts = layouts.size();
102 16 : Layout* oldLayout = (oldIndex >= nLayouts) ? 0 : layouts[oldIndex];
103 16 : Layout* newLayout = (newIndex >= nLayouts) ? 0 : layouts[newIndex];
104 :
105 16 : if( oldLayout )
106 8 : oldLayout->trigger( this, false );
107 :
108 16 : if( newIndex == LB_UNDEFINED_UINT32 )
109 8 : return;
110 :
111 8 : Super::activateLayout( newIndex );
112 :
113 8 : if( newLayout )
114 8 : newLayout->trigger( this, true );
115 : }
116 :
117 0 : void Canvas::postDelete()
118 : {
119 0 : _state = STATE_DELETE;
120 0 : getConfig()->postNeedsFinish();
121 0 : }
122 :
123 : }
124 : }
125 :
126 : #include "nodeFactory.h"
127 : #include "../fabric/canvas.ipp"
128 :
129 : template class eq::fabric::Canvas< eq::server::Config, eq::server::Canvas,
130 : eq::server::Segment, eq::server::Layout >;
131 : /** @cond IGNORE */
132 : template std::ostream& eq::fabric::operator << ( std::ostream&,
133 : const eq::fabric::Canvas< eq::server::Config, eq::server::Canvas,
134 27 : eq::server::Segment, eq::server::Layout >& );
135 : /** @endcond */
|